Fix user defined rules to cast ENUM to Text.

The MySQL enum are casted to PostgreSQL enum types just fine, but sometimes
that's not what the user wants. In case when we have a CAST rule for an ENUM
column, recognize the fact and respect user choice.

Fixes #608.
This commit is contained in:
Dimitri Fontaine 2017-08-10 18:01:17 +02:00
parent 049a1199c2
commit 981b801ce7

View File

@ -190,12 +190,22 @@
dtype
ctype
nil)))
;;
;; We might have user-defined cast rules e.g. converting an ENUM
;; to text, in which case we have nothing to do here. We set a
;; PostgreSQL enum only when the casting rules already generated
;; the target type name.
;;
;; FIXME: why call enum-or-set-name twice, once from
;; *mysql-default-cast-rules* and once here explicitely?
;;
(when (string= sqltype-name (column-type-name pgcol))
(setf (column-type-name pgcol)
(make-sqltype :name sqltype-name
:type (intern (string-upcase dtype)
(find-package "KEYWORD"))
:source-def ctype
:extra (explode-mysql-enum ctype)))))
:extra (explode-mysql-enum ctype))))))
;; extra triggers
;;