From 5ba42edb0cd34902160164a553110bcbcec086a9 Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Thu, 25 Jan 2018 23:29:36 +0100 Subject: [PATCH] Review misleading error message with schema not found. It might be that the schema exists but we didn't find what we expected to in there, so that it didn't make it to pgloader's internal catalogs. Be friendly to the user with a better error message. Fix #713. --- src/pgsql/merge-catalogs.lisp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/pgsql/merge-catalogs.lisp b/src/pgsql/merge-catalogs.lisp index 9e437e2..bec3be5 100644 --- a/src/pgsql/merge-catalogs.lisp +++ b/src/pgsql/merge-catalogs.lisp @@ -32,8 +32,15 @@ (find-schema target-catalog schema-name))) (unless target-schema - (error "pgloader failed to find schema ~s in target catalog" - schema-name)) + ;; it could be that we found nothing in the schema because of + ;; including/excluding rules, or that the schema doesn't + ;; exists, let's double check + (let ((schema-list (list-schemas))) + (if (member schema-name schema-list :test #'string=) + (error "pgloader failed to find anything in schema ~s in target catalog." + schema-name) + (error "pgloader failed to find schema ~s in target catalog." + schema-name)))) (loop :for source-table :in (schema-table-list source-schema) :for target-table := (find-table target-schema