From bc4927bbbb2bb7d941501086fb57a172832ef4e9 Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Fri, 20 Sep 2013 13:32:27 +0200 Subject: [PATCH] Allow to omit the target type definition in a MySQL cast definition. --- parser.lisp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/parser.lisp b/parser.lisp index 1f538e9..33a8b18 100644 --- a/parser.lisp +++ b/parser.lisp @@ -486,10 +486,18 @@ Here's a quick description of the format we're parsing here: (declare (ignore using)) (intern (string-upcase fname) :pgloader.transforms)))) +(defun fix-target-type (source target) + "When target has :type nil, steal the source :type definition." + (unless (getf target :type) + (setf (getf target :type) (getf source :type)) + target)) + (defrule cast-rule (and cast-source cast-def (? cast-function)) (:lambda (cast) (destructuring-bind (source target function) cast - (list :source source :target target :using function)))) + (list :source source + :target (fix-target-type source target) + :using function)))) (defrule another-cast-rule (and #\, ignore-whitespace cast-rule) (:lambda (source)