mirror of
https://github.com/dimitri/pgloader.git
synced 2026-03-19 11:01:10 +01:00
Fix MySQL ENUM and SET parsing, fixing #120.
MySQL ENUM syntax is more complex than it first looked, allowing for escaping and spaces, so use a more complex parser here. Fortunately, the syntax looks like a CSV row enough that cl-csv can be re-used for that.
This commit is contained in:
parent
93990317f3
commit
bb2c7e4e17
@ -9,10 +9,9 @@
|
||||
;;;
|
||||
(defun explode-mysql-enum (ctype)
|
||||
"Convert MySQL ENUM expression into a list of labels."
|
||||
;; from: "ENUM('small', 'medium', 'large')"
|
||||
;; to: ("small" "medium" "large")
|
||||
(mapcar (lambda (x) (string-trim "' )" x))
|
||||
(sq:split-sequence #\, ctype :start (position #\' ctype))))
|
||||
(cl-ppcre:register-groups-bind (list)
|
||||
("(?i)(?:ENUM|SET)\\s*\\((.*)\\)" ctype)
|
||||
(first (cl-csv:read-csv list :separator #\, :quote #\' :escape "\\"))))
|
||||
|
||||
(defun get-enum-type-name (table-name column-name identifier-case)
|
||||
"Return the Type Name we're going to use in PostgreSQL."
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user