Allow for empty-string SQLite column types, fix #220 again.

This commit is contained in:
Dimitri Fontaine 2015-04-30 17:18:14 +02:00
parent 95a5eb3184
commit ebc0dcda4f

View File

@ -51,6 +51,9 @@
(defun normalize (sqlite-type-name) (defun normalize (sqlite-type-name)
"SQLite only has a notion of what MySQL calls column_type, or ctype in the "SQLite only has a notion of what MySQL calls column_type, or ctype in the
CAST machinery. Transform it to the data_type, or dtype." CAST machinery. Transform it to the data_type, or dtype."
(if (string= sqlite-type-name "")
;; yes SQLite allows for empty type names
"text"
(let* ((sqlite-type-name (string-downcase sqlite-type-name)) (let* ((sqlite-type-name (string-downcase sqlite-type-name))
(tokens (remove-if (lambda (token) (tokens (remove-if (lambda (token)
(or (member token '("unsigned" "short" (or (member token '("unsigned" "short"
@ -60,7 +63,7 @@
(char= #\( (aref token 0)))) (char= #\( (aref token 0))))
(sq:split-sequence #\Space sqlite-type-name)))) (sq:split-sequence #\Space sqlite-type-name))))
(assert (= 1 (length tokens))) (assert (= 1 (length tokens)))
(first tokens))) (first tokens))))
(defun ctype-to-dtype (sqlite-type-name) (defun ctype-to-dtype (sqlite-type-name)
"In SQLite we only get the ctype, e.g. int(7), but here we want the base "In SQLite we only get the ctype, e.g. int(7), but here we want the base