Allow database names to contain spaces.

Then they must be quoted (single or double quotes accepted), of course.

Fix #614.
This commit is contained in:
Dimitri Fontaine 2017-08-24 23:05:26 +02:00
parent 9263baeb49
commit 9d4743f598
3 changed files with 12 additions and 15 deletions

View File

@ -86,7 +86,7 @@
(append (list :host (when host (process-hostname host)))
port))))
(defrule dsn-dbname (and "/" (? namestring))
(defrule dsn-dbname (and "/" (? maybe-quoted-namestring))
(:destructure (slash dbname)
(declare (ignore slash))
(list :dbname dbname)))
@ -105,10 +105,6 @@
(declare (ignore key e))
(cons :use-ssl val))))
(defrule maybe-quoted-namestring (or double-quoted-namestring
quoted-namestring
namestring))
(defrule qualified-table-name (and maybe-quoted-namestring
"."
maybe-quoted-namestring)

View File

@ -94,12 +94,8 @@
(defrule mysql-prefix "mysql://" (:constant (list :type :mysql)))
(defrule mysql-dsn-dbname (and "/" (* (or (alpha-char-p character)
(digit-char-p character)
punct)))
(:destructure (slash dbname)
(declare (ignore slash))
(list :dbname (text dbname))))
(defrule mysql-dsn-dbname (and "/" maybe-quoted-namestring)
(:lambda (m-d-d) (list :dbname (text (second m-d-d)))))
(defrule mysql-uri (and mysql-prefix
(? dsn-user-password)

View File

@ -39,11 +39,11 @@
punct)))
(:text t))
(defrule double-quoted-namestring (and #\" namestring #\")
(:destructure (open name close) (declare (ignore open close)) name))
(defrule double-quoted-namestring (and #\" (* (not #\")) #\")
(:lambda (dqn) (text (second dqn))))
(defrule quoted-namestring (and #\' namestring #\')
(:destructure (open name close) (declare (ignore open close)) name))
(defrule quoted-namestring (and #\' (+ (not #\')) #\')
(:lambda (dqn) (text (second dqn))))
(defrule name (or namestring quoted-namestring)
(:text t))
@ -52,3 +52,8 @@
(:destructure (whitespace name) (declare (ignore whitespace)) name))
(defrule namestring-or-regex (or quoted-namestring quoted-regex))
(defrule maybe-quoted-namestring (or double-quoted-namestring
quoted-namestring
namestring))