mirror of
https://github.com/dimitri/pgloader.git
synced 2026-05-05 10:56:10 +02:00
Fix MySQL Enum parsing.
We use a CSV parser for the MySQL enum values, but the quote escaping wasn't
properly setup: MySQL quotes ENUM values with a single-quote (') and uses
two of them ('') for escaping single-quotes when found in the ENUM value
itself.
Fixes #597.
This commit is contained in:
parent
3103b0dc72
commit
5c1c4bf3ff
@ -26,7 +26,9 @@
|
||||
((:enum :set)
|
||||
(format stream "CREATE TYPE ~a AS ENUM (~{'~a'~^, ~});"
|
||||
(sqltype-name sqltype)
|
||||
(sqltype-extra sqltype)))))
|
||||
(mapcar (lambda (value)
|
||||
(cl-ppcre:regex-replace-all "'" value "''"))
|
||||
(sqltype-extra sqltype))))))
|
||||
|
||||
(defmethod format-drop-sql ((sqltype sqltype) &key (stream nil) cascade if-exists)
|
||||
(format stream "DROP TYPE~:[~; IF EXISTS~] ~a~@[ CASCADE~];"
|
||||
|
||||
@ -157,7 +157,7 @@
|
||||
"Convert MySQL ENUM expression into a list of labels."
|
||||
(cl-ppcre:register-groups-bind (list)
|
||||
("(?i)(?:ENUM|SET)\\s*\\((.*)\\)" ctype)
|
||||
(first (cl-csv:read-csv list :separator #\, :quote #\' :escape "\\"))))
|
||||
(first (cl-csv:read-csv list :separator #\, :quote #\' :escape "''"))))
|
||||
|
||||
(defmethod cast ((col mysql-column))
|
||||
"Return the PostgreSQL type definition from given MySQL column definition."
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user