Allow usernames and dbnames starting with digits (again).

It turns out that the rules about the names of users and databases are more
lax than pgloader would know, so it might be a good move for our DSN parsing
to accept more values and then let the source/target systems to complain
when something goes wrong.

See #230 which got broke again somewhere.
This commit is contained in:
Dimitri Fontaine 2018-10-20 19:28:19 +02:00
parent 6e7ea90806
commit f8460c1705
2 changed files with 7 additions and 9 deletions

View File

@ -25,7 +25,7 @@
(defrule doubled-at-sign (and "@@") (:constant "@"))
(defrule doubled-colon (and "::") (:constant ":"))
(defrule password (+ (or (not "@") doubled-at-sign)) (:text t))
(defrule username (and (or #\_ (alpha-char-p character))
(defrule username (and (or #\_ (alpha-char-p character) (digit-char-p character))
(* (or (alpha-char-p character)
(digit-char-p character)
#\.
@ -87,10 +87,11 @@
(append (list :host (when host (process-hostname host)))
port))))
(defrule dsn-dbname (and "/" (? maybe-quoted-namestring))
(:destructure (slash dbname)
(declare (ignore slash))
(list :dbname dbname)))
(defrule dsn-dbname (and "/" (? (* (or (alpha-char-p character)
(digit-char-p character)
punct))))
(:lambda (dbn)
(list :dbname (text (second dbn)))))
(defrule dsn-option-ssl-disable "disable" (:constant :no))
(defrule dsn-option-ssl-allow "allow" (:constant :try))

View File

@ -95,9 +95,6 @@
(defrule mysql-prefix "mysql://" (:constant (list :type :mysql)))
(defrule mysql-dsn-dbname (and "/" maybe-quoted-namestring)
(:lambda (m-d-d) (list :dbname (text (second m-d-d)))))
(defrule mysql-dsn-option-usessl-true "true" (:constant :yes))
(defrule mysql-dsn-option-usessl-false "false" (:constant :no))
@ -123,7 +120,7 @@
(defrule mysql-uri (and mysql-prefix
(? dsn-user-password)
(? dsn-hostname)
mysql-dsn-dbname
dsn-dbname
(? mysql-dsn-options))
(:lambda (uri)
(destructuring-bind (&key type