add :plist and :plists format specifiers (courtesy of Andrey Moskvitin)
Sat Mar 27 00:52:08 PDT 2010
* add :plist and :plists format specifiers (courtesy of Andrey Moskvitin)
Warning: CRC errors found. These are probably harmless but should be repaired.
See 'darcs gzcrcs --help' for more information.
diff -rN -u old-postmodern/doc/postmodern.html new-postmodern/doc/postmodern.html
--- old-postmodern/doc/postmodern.html 2014-07-26 06:14:24.000000000 -0700
+++ new-postmodern/doc/postmodern.html 2014-07-26 06:14:24.000000000 -0700
@@ -229,6 +229,9 @@
<tr><td><code>:str-alist</code></td><td>Return a single row as an alist, with
strings for names.</td></tr>
+ <tr><td><code>:plists</code></td><td>Return a list of plists which map column
+ names to values,with the names represented as keywords.</td></tr>
+ <tr><td><code>:plist</code></td><td>Return a single row as a plist.</td></tr>
<tr><td><code>:column</code></td><td>Return a single column as a list.</td></tr>
<tr><td><code>:single</code></td><td>Return a single value.</td></tr>
<tr><td><code>:single!</code></td><td>Like <code>:single</code>,
diff -rN -u old-postmodern/postmodern/query.lisp new-postmodern/postmodern/query.lisp
--- old-postmodern/postmodern/query.lisp 2014-07-26 06:14:24.000000000 -0700
+++ new-postmodern/postmodern/query.lisp 2014-07-26 06:14:24.000000000 -0700
@@ -9,6 +9,14 @@
:for symbol :in symbols
:collect (cons symbol (next-field field))))))
+;; Like symbol-alist-row-reader, but return plist
+(def-row-reader symbol-plist-row-reader (fields)
+ (let ((symbols (map 'list (lambda (desc) (from-sql-name (field-name desc))) fields)))
+ (loop :while (next-row)
+ :collect (loop :for field :across fields
+ :for symbol :in symbols
+ :collect symbol :collect (next-field field)))))
;; A row-reader for reading only a single column, and returning a list
;; of single values.
(def-row-reader column-row-reader (fields)
@@ -26,6 +34,8 @@
(:alist symbol-alist-row-reader single-row)
(:str-alists alist-row-reader all-rows)
(:str-alist alist-row-reader single-row)
+ (:plists symbol-plist-row-reader nil)
+ (:plist symbol-plist-row-reader t)
(:column column-row-reader all-rows)
(:single column-row-reader single-row)
(:single! column-row-reader single-row!))