Subject: bug#23566: sql-sqlite: selecting database file is crippled)

From: Rolf Ade <[email-masked]>
Date: Wed, 04 Jan 2017 00:42:56 +0100

Rolf Ade <[email-masked]> writes:
> [...]
> diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
> index d6c9516..55ba320 100644
> --- a/lisp/progmodes/sql.el
> +++ b/lisp/progmodes/sql.el
> @@ -933,10 +933,10 @@ 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"
> +  :version "26.1"
>    :group 'SQL)
>  
>  ;; Customization for MySQL
> @@ -2958,9 +2958,11 @@ sql-get-login-ext
>                          (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))
> +                                 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

Sorry for any confusion - due to new years holidays I'm not on my main
box and I missed in my last patch the part "allow creation of new SQLite
database files".

Commit message:

Fix selecting SQLite database files with sql-mode (bug#23566)

* lisp/progmodes/sql.el (sql-sqlite-login-params): Allow any name as
SQLite database file name, by default.
(sql-get-login-ext): Fixed read-file-name arguments to provide
path completion even if a database name pattern is customized and to
allow creation of new SQLite database files.

Copyright-paperwork-exempt: yes

diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
index d6c9516..7156348 100644
--- a/lisp/progmodes/sql.el
+++ b/lisp/progmodes/sql.el
@@ -933,10 +933,10 @@ 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"
+  :version "26.1"
   :group 'SQL)
 
 ;; Customization for MySQL
@@ -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))
+                                 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