1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-30 12:21:25 -08:00

(sqlite-mode--column-names): Suppport nested parens

* lisp/sqlite-mode.el (sqlite-mode--column-names): Make parsing
more resilient (bug#55363).

Copyright-paperwork-exempt: yes
This commit is contained in:
Yoav Marco 2022-05-11 14:05:37 +02:00 committed by Lars Ingebrigtsen
parent f8bafead0b
commit 72b1007987

View file

@ -129,15 +129,23 @@
(insert (format " %s\n" column))))))))
(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)))))
(mapcar
#'string-trim
(split-string (replace-regexp-in-string "^.*(\\|)$" "" sql) ","))))
(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 (
",")))))
(defun sqlite-mode-list-data ()
"List the data from the table under point."