branch: elpa/emacsql
commit a6dbb52a3ce16a2ff4630f7f3806ad8d6cd66570
Author: Christopher Wellons <well...@nullprogram.com>
Commit: Christopher Wellons <well...@nullprogram.com>

    Add flatten option.
---
 emacsql.el | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/emacsql.el b/emacsql.el
index ed81295794..07f1404a8a 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -154,14 +154,18 @@ buffer. This is for debugging purposes."
                                         (buffer-substring
                                          (- (point-max) 2) (point-max)))))))
 
-(defun emacsql--parse (emacsql)
-  "Parse a query result into an s-expression."
+(defun emacsql--parse (emacsql &rest flatten)
+  "Parse a query result into an s-expression.
+If FLATTEN is non-nil, don't include column names."
   (with-current-buffer (emacsql-buffer emacsql)
     (let ((standard-input (current-buffer)))
       (setf (point) (point-min))
       (cl-loop until (looking-at "#")
-               for (name _= value) = (list (read) (read) (read))
-               collect (cons name value) into row
+               for name = (read)
+               do (forward-char 3)
+               for value = (read)
+               when flatten collect value into row
+               else collect (cons name value) into row
                do (forward-char)
                when (or (looking-at "\n") (looking-at "#"))
                collect row into rows and do (setf row ())

Reply via email to