mirror of
https://github.com/dimitri/pgloader.git
synced 2026-05-04 18:36:12 +02:00
Merge pull request #18 from Sectoid/fix-mysql-quoting
Fixing "quote identifiers" option for MySQL conversions
This commit is contained in:
commit
bcb058d9ba
@ -194,16 +194,19 @@ GROUP BY table_name, index_name;" dbname))
|
||||
for (name . indexes) in schema
|
||||
collect (cons name (reverse indexes))))))))
|
||||
|
||||
(defun set-table-oids (all-indexes)
|
||||
(defun set-table-oids (all-indexes &key identifier-case)
|
||||
"MySQL allows using the same index name against separate tables, which
|
||||
PostgreSQL forbids. To get unicity in index names without running out of
|
||||
characters (we are allowed only 63), we use the table OID instead.
|
||||
|
||||
This function grabs the table OIDs in the PostgreSQL database and update
|
||||
the definitions with them."
|
||||
(let* ((table-names (mapcar #'car all-indexes))
|
||||
(let* ((table-names (mapcar #'(lambda (table-name)
|
||||
(apply-identifier-case table-name identifier-case))
|
||||
(mapcar #'car all-indexes)))
|
||||
(table-oids (pgloader.pgsql:list-table-oids table-names)))
|
||||
(loop for (table-name . indexes) in all-indexes
|
||||
(loop for (table-name-raw . indexes) in all-indexes
|
||||
for table-name = (apply-identifier-case table-name-raw identifier-case)
|
||||
for table-oid = (cdr (assoc table-name table-oids :test #'string=))
|
||||
unless table-oid do (error "OID not found for ~s." table-name)
|
||||
do (loop for index in indexes
|
||||
|
||||
@ -212,7 +212,8 @@
|
||||
;; MySQL allows the same index name being used against several
|
||||
;; tables, so we add the PostgreSQL table OID in the index name,
|
||||
;; to differenciate. Set the table oids now.
|
||||
(set-table-oids all-indexes)
|
||||
(set-table-oids all-indexes
|
||||
:identifier-case identifier-case)
|
||||
|
||||
;; If asked to materialize views, now is the time to create
|
||||
;; the target tables for them
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user