]> git.eshelyaron.com Git - emacs.git/commitdiff
Remove column quoting from sqlite-mode
authorThomas Hilke <t.hilke@rollomatic.ch>
Fri, 15 Sep 2023 08:30:25 +0000 (10:30 +0200)
committerEli Zaretskii <eliz@gnu.org>
Sun, 17 Sep 2023 10:02:50 +0000 (13:02 +0300)
* lisp/sqlite-mode.el (sqlite-mode--column-names): Unquote column
name.  (Bug#65998)

Copyright-paperwork-exempt: yes

lisp/sqlite-mode.el

index 71c9e57fc12d2404aee1c8c1adbfc572be3870c9..38e9f84b8425aa2194ddfcd7506a09d082fc433b 100644 (file)
 
 (defun sqlite-mode--column-names (table)
   "Return a list of the column names for TABLE."
-  (let ((sql
-         (caar
-          (sqlite-select
-           sqlite--db
-           "select sql from sqlite_master where tbl_name = ? AND type = 'table'"
-           (list table)))))
-    (with-temp-buffer
-      (insert sql)
-      (mapcar #'string-trim
-              (split-string
-               ;; Extract the args to CREATE TABLE.  Point is
-               ;; currently at its end.
-               (buffer-substring
-                (1- (point))                          ; right before )
-                (1+ (progn (backward-sexp) (point)))) ; right after (
-               ",")))))
+  (mapcar (lambda (row) (nth 1 row)) (sqlite-select sqlite--db (format "pragma table_info(%s)" table))))
 
 (defun sqlite-mode-list-data ()
   "List the data from the table under point."