From fbe5bc5cb49e5ec856aec3516d1f283ca5ce4f5b Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 6 Jul 2022 11:53:55 +0200 Subject: [PATCH] fixup! fixup! fixup! [IMP] use sqlparse also to determine which ddl to update --- pglogical/hooks.py | 6 ++++++ pglogical/tests/test_pglogical.py | 1 + 2 files changed, 7 insertions(+) diff --git a/pglogical/hooks.py b/pglogical/hooks.py index ba992634..cf8f5eb6 100644 --- a/pglogical/hooks.py +++ b/pglogical/hooks.py @@ -35,6 +35,12 @@ def schema_qualify(parsed_query, schema="public"): # this is invalid sql next_token = False break + if next_token.is_keyword and next_token.normalized in ( + 'TEMP', 'TEMPORARY' + ): + # don't qualify CREATE TEMP TABLE statements + is_qualified = True + break if not (next_token.is_whitespace or next_token.is_keyword): break yield next_token diff --git a/pglogical/tests/test_pglogical.py b/pglogical/tests/test_pglogical.py index fc384d3b..59a39a7b 100644 --- a/pglogical/tests/test_pglogical.py +++ b/pglogical/tests/test_pglogical.py @@ -125,6 +125,7 @@ class TestPglogical(TransactionCase): 'drop table', "alter table 'test'", 'ALTER TABLE "testtable" ADD COLUMN "test_field" double precision', + 'CREATE TEMP TABLE "temptable" (col1 char)', ): qualified_query = ''.join( ''.join(str(token) for token in schema_qualify(parsed_query))