Allow SQLite type names such as "double precision".

The parsing of the type names from the SQLite catalogs needs to allow for
names with spaces in them, because SQLite allows that too.

Fixes #921.
This commit is contained in:
Dimitri Fontaine 2020-05-09 23:55:59 +02:00
parent 11d926126e
commit 1bdc0ee5f4
3 changed files with 17 additions and 7 deletions

View File

@ -31,20 +31,27 @@
(defrule sqlite-typemod (or sqlite-double-typemod sqlite-single-typemod))
(defrule sqlite-type-name (and (* extra-qualifiers)
(+ (or (alpha-char-p character) #\_))
;; type names may be "double quoted", such as "double precision"
(defrule sqlite-type-name (or (+ (and (not extra-qualifiers)
(+ (or (alpha-char-p character) #\_))
(? " "))))
(:text t))
(defrule sqlite-type-expr (and (* extra-qualifiers)
sqlite-type-name
(* extra-qualifiers)
ignore-whitespace
(? sqlite-typemod)
ignore-whitespace
(* extra-qualifiers))
(:lambda (tn) (list (text (second tn))
(fifth tn)
(remove-if #'null
(append (first tn) (third tn) (seventh tn))))))
(:lambda (tn)
(list (text (second tn))
(fifth tn)
(remove-if #'null
(append (first tn) (third tn) (seventh tn))))))
(defun parse-sqlite-type-name (type-name)
(if (string= type-name "")
;; yes SQLite allows for empty type names
"text"
(values-list (parse 'sqlite-type-name (string-downcase type-name)))))
(values-list (parse 'sqlite-type-expr (string-downcase type-name)))))

View File

@ -35,6 +35,9 @@
(:source (:type "double") :target (:type "double precision")
:using pgloader.transforms::float-to-string)
(:source (:type "double precision") :target (:type "double precision")
:using pgloader.transforms::float-to-string)
(:source (:type "numeric") :target (:type "numeric" :drop-typemod nil)
:using pgloader.transforms::float-to-string)

Binary file not shown.