[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#23566: sql-sqlite: selecting database file is crippled)
From: |
npostavs |
Subject: |
bug#23566: sql-sqlite: selecting database file is crippled) |
Date: |
Sat, 31 Dec 2016 23:03:07 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) |
tags 23566 patch
quit
Hi,
I'm sorry that nobody responded to your bug report earlier. I expect
the problem is that there aren't any sqlite experienced people working
on Emacs right now (at least, ignorance of sql(ite) is why *I* passed on
this bug the first time around).
Rolf Ade <rolf@pointsman.de> writes:
> Therefor I propose this slightly more elaborate patch:
>
> diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
> index 9608a7d..c3c61f2 100644
> --- a/lisp/progmodes/sql.el
> +++ b/lisp/progmodes/sql.el
> @@ -933,7 +933,7 @@ sql-sqlite-options
> :version "20.8"
> :group 'SQL)
>
> -(defcustom sql-sqlite-login-params '((database :file
> ".*\\.\\(db\\|sqlite[23]?\\)"))
> +(defcustom sql-sqlite-login-params '((database :file nil))
> "List of login parameters needed to connect to SQLite."
> :type 'sql-login-params
> :version "24.1"
The :version should be updated when the default value is changed.
> @@ -2954,13 +2954,15 @@ sql-get-login-ext
> ((plist-member plist :file)
> (expand-file-name
> (read-file-name prompt
> - (file-name-directory last-value) default t
> + (file-name-directory last-value) default 'confirm
> (file-name-nondirectory last-value)
> (when (plist-get plist :file)
> `(lambda (f)
> - (string-match
> - (concat "\\<" ,(plist-get plist :file) "\\>")
> - (file-name-nondirectory f)))))))
> + (if (not(file-regular-p f))
^^
missed a space here
> + t
> + (string-match
> + (concat "\\<" ,(plist-get plist :file) "\\>")
> + (file-name-nondirectory f))))))))
>
> ((plist-member plist :completion)
> (completing-read prompt-def (plist-get plist :completion) nil t
>
This looks reasonable to me, and is small enough to install without
copyright assignment. Could you add a commit message too? (format as
described in CONTRIBUTE)
>
> There is no need for fear, a user may by mistake damage a non SQLite
> file (by not restricting the file select to a small number of file name
> suffixes (which would't be a great strategy. if such fear had ground).
> Every SQLite database file has a 100 byte long database header described
> here: https://www.sqlite.org/fileformat.html#the_database_header
I think the idea is more to restrict the completion to database files
for convenience, not protection from damage. But since there doesn't
seem to be much of a convention for sqlite file extensions, setting the
default to nil seems okay.