From 44a2bd14d4b7a1ae814f759546885fb3c5e9520a Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Tue, 12 Jan 2016 14:55:17 +0100 Subject: [PATCH] Fix custom CAST rules with expressions, fix #322. In a previous commit the typemod matching code had been broken, and we failed to notice that until now. Thanks to bug report #322 we just got the memo... Add a test case in the local-only MySQL database. The regression testing facilities should be improved to be able to test a full database, and then to dynamically create said database from code or something to ease test coverage of those cases. --- src/sources/common/casting-rules.lisp | 4 ++-- test/parse/hans.goeuro.load | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sources/common/casting-rules.lisp b/src/sources/common/casting-rules.lisp index 03d4ec5..bbd239c 100644 --- a/src/sources/common/casting-rules.lisp +++ b/src/sources/common/casting-rules.lisp @@ -27,7 +27,7 @@ (mapcar #'parse-integer (sq:split-sequence #\, column-type :start (+ 1 start-1) :end end)) - (cons a b)))))) + (list a b)))))) (defun typemod-expr-matches-p (rule-typemod-expr typemod) "Check if an expression such as (< 10) matches given typemod." @@ -98,7 +98,7 @@ (t type))) (pg-typemod (when source-typemod - (destructuring-bind (a . b) source-typemod + (destructuring-bind (a &optional b) source-typemod (format nil "(~a~:[~*~;,~a~])" a b b))))) (make-column :name (apply-identifier-case source-column-name) :type-name type-name diff --git a/test/parse/hans.goeuro.load b/test/parse/hans.goeuro.load index b21ab88..d570df8 100644 --- a/test/parse/hans.goeuro.load +++ b/test/parse/hans.goeuro.load @@ -26,8 +26,9 @@ LOAD DATABASE column ascii.s using byte-vector-to-bytea, column enumerate.foo using empty-string-to-null, - column ip.ip_address to inet keep not null drop typemod + column ip.ip_address to inet keep not null drop typemod, + type decimal when (= precision 1) to boolean drop typemod MATERIALIZE VIEWS nonexisting, d as $$