File tree Expand file tree Collapse file tree 3 files changed +24
-10
lines changed Expand file tree Collapse file tree 3 files changed +24
-10
lines changed Original file line number Diff line number Diff line change @@ -60,14 +60,18 @@ buffer. This is for debugging purposes."
60
60
(cl-defmethod emacsql-send-message
61
61
((connection emacsql-sqlite-builtin-connection) message)
62
62
(condition-case err
63
- (mapcar (lambda (row )
64
- (mapcar (lambda (col )
65
- (cond ((null col) nil )
66
- ((equal col " " ) " " )
67
- ((numberp col) col)
68
- (t (read col))))
69
- row))
70
- (sqlite-select (oref connection handle) message nil nil ))
63
+ (let ((include-header emacsql-include-header))
64
+ (mapcar (lambda (row )
65
+ (prog1 (mapcar (lambda (col )
66
+ (cond (include-header col)
67
+ ((null col) nil )
68
+ ((equal col " " ) " " )
69
+ ((numberp col) col)
70
+ (t (read col))))
71
+ row)
72
+ (setq include-header nil )))
73
+ (sqlite-select (oref connection handle) message nil
74
+ (and emacsql-include-header 'full ))))
71
75
((sqlite-error sqlite-locked-error)
72
76
(if (stringp (cdr err))
73
77
(signal 'emacsql-error (list (cdr err)))
Original file line number Diff line number Diff line change @@ -83,6 +83,12 @@ Also see http://www.sqlite.org/lang_keywords.html.")
83
83
Elements have the form (ERRCODE SYMBOLIC-NAME EMACSQL-ERROR
84
84
ERRSTR). Also see https://www.sqlite.org/rescode.html." )
85
85
86
+ (defconst emacsql-include-header nil
87
+ " Whether to include names of columns as an additional row.
88
+ Never enable this globally, only let-bind it around calls to `emacsql' .
89
+ Currently only supported by `emacsql-sqlite-builtin-connection' and
90
+ `emacsql-sqlite-module-connection' ." )
91
+
86
92
; ;; Utilities
87
93
88
94
(defun emacsql-sqlite-open (file &optional debug )
Original file line number Diff line number Diff line change @@ -64,10 +64,14 @@ buffer. This is for debugging purposes."
64
64
(cl-defmethod emacsql-send-message
65
65
((connection emacsql-sqlite-module-connection) message)
66
66
(condition-case err
67
- (let (rows)
67
+ (let ((include-header emacsql-include-header)
68
+ (rows ()))
68
69
(sqlite3-exec (oref connection handle)
69
70
message
70
- (lambda (_ row __ )
71
+ (lambda (_ row header )
72
+ (when include-header
73
+ (push header rows)
74
+ (setq include-header nil ))
71
75
(push (mapcar (lambda (col )
72
76
(cond ((null col) nil )
73
77
((equal col " " ) " " )
You can’t perform that action at this time.
0 commit comments