From 5fd1e9f3aadd27df85ac49d06ac6797706b2ff3c Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Sat, 25 Feb 2017 17:50:25 +0100 Subject: [PATCH] Fix catalog merge hasards. When reading table names from PostgreSQL, we might find some that need systematic quoting (such as names that begin with a digit). In that case, when later comparing the catalogs to match source database table names against PostgreSQL catalog table names, we need to unquote the PostgreSQL table name we are using. In passing, force the *identifier-case* to :none when reading object names from the PostgreSQL catalogs. --- src/pgsql/merge-catalogs.lisp | 3 ++- src/pgsql/pgsql-schema.lisp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pgsql/merge-catalogs.lisp b/src/pgsql/merge-catalogs.lisp index 54baa5d..8e7c7e5 100644 --- a/src/pgsql/merge-catalogs.lisp +++ b/src/pgsql/merge-catalogs.lisp @@ -37,7 +37,8 @@ (loop :for source-table :in (schema-table-list source-schema) :for target-table := (find-table target-schema - (table-name source-table)) + (ensure-unquoted + (table-name source-table))) :do (if target-table (progn ;; re-use indexes and fkeys from target-catalog diff --git a/src/pgsql/pgsql-schema.lisp b/src/pgsql/pgsql-schema.lisp index 3907a37..9f2aca6 100644 --- a/src/pgsql/pgsql-schema.lisp +++ b/src/pgsql/pgsql-schema.lisp @@ -8,7 +8,8 @@ &key table source-catalog including excluding) "Fetch PostgreSQL catalogs for the target database. A PostgreSQL connection must be opened." - (let* ((catalog (make-catalog :name dbname)) + (let* ((*identifier-case* :none) + (catalog (make-catalog :name dbname)) (including (cond ((and table (not including)) (make-including-expr-from-table table))