Skip to content

Commit 1bdc0ee

Browse files
committed
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 dimitri#921.
1 parent 11d9261 commit 1bdc0ee

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

src/parsers/parse-sqlite-type-name.lisp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,27 @@
3131

3232
(defrule sqlite-typemod (or sqlite-double-typemod sqlite-single-typemod))
3333

34-
(defrule sqlite-type-name (and (* extra-qualifiers)
35-
(+ (or (alpha-char-p character) #\_))
34+
;; type names may be "double quoted", such as "double precision"
35+
(defrule sqlite-type-name (or (+ (and (not extra-qualifiers)
36+
(+ (or (alpha-char-p character) #\_))
37+
(? " "))))
38+
(:text t))
39+
40+
(defrule sqlite-type-expr (and (* extra-qualifiers)
41+
sqlite-type-name
3642
(* extra-qualifiers)
3743
ignore-whitespace
3844
(? sqlite-typemod)
3945
ignore-whitespace
4046
(* extra-qualifiers))
41-
(:lambda (tn) (list (text (second tn))
42-
(fifth tn)
43-
(remove-if #'null
44-
(append (first tn) (third tn) (seventh tn))))))
47+
(:lambda (tn)
48+
(list (text (second tn))
49+
(fifth tn)
50+
(remove-if #'null
51+
(append (first tn) (third tn) (seventh tn))))))
4552

4653
(defun parse-sqlite-type-name (type-name)
4754
(if (string= type-name "")
4855
;; yes SQLite allows for empty type names
4956
"text"
50-
(values-list (parse 'sqlite-type-name (string-downcase type-name)))))
57+
(values-list (parse 'sqlite-type-expr (string-downcase type-name)))))

src/sources/sqlite/sqlite-cast-rules.lisp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
(:source (:type "double") :target (:type "double precision")
3636
:using pgloader.transforms::float-to-string)
3737

38+
(:source (:type "double precision") :target (:type "double precision")
39+
:using pgloader.transforms::float-to-string)
40+
3841
(:source (:type "numeric") :target (:type "numeric" :drop-typemod nil)
3942
:using pgloader.transforms::float-to-string)
4043

test/sqlite/sqlite.db

4 KB
Binary file not shown.

0 commit comments

Comments
 (0)