mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
fixup! fixup! [IMP] use sqlparse also to determine which ddl to update
This commit is contained in:
@@ -20,6 +20,7 @@ def schema_qualify(parsed_query, schema="public"):
|
|||||||
token_iterator = parsed_query.flatten()
|
token_iterator = parsed_query.flatten()
|
||||||
Name = sqlparse.tokens.Name
|
Name = sqlparse.tokens.Name
|
||||||
Punctuation = sqlparse.tokens.Punctuation
|
Punctuation = sqlparse.tokens.Punctuation
|
||||||
|
Symbol = sqlparse.tokens.String.Symbol
|
||||||
is_qualified = False
|
is_qualified = False
|
||||||
for token in token_iterator:
|
for token in token_iterator:
|
||||||
yield token
|
yield token
|
||||||
@@ -39,7 +40,7 @@ def schema_qualify(parsed_query, schema="public"):
|
|||||||
yield next_token
|
yield next_token
|
||||||
if not next_token:
|
if not next_token:
|
||||||
continue
|
continue
|
||||||
if next_token.ttype != Name:
|
if next_token.ttype not in (Name, Symbol):
|
||||||
yield next_token
|
yield next_token
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -124,11 +124,15 @@ class TestPglogical(TransactionCase):
|
|||||||
RETURNS NULL ON NULL INPUT''',
|
RETURNS NULL ON NULL INPUT''',
|
||||||
'drop table',
|
'drop table',
|
||||||
"alter table 'test'",
|
"alter table 'test'",
|
||||||
|
'ALTER TABLE "testtable" ADD COLUMN "test_field" double precision',
|
||||||
):
|
):
|
||||||
qualified_query = ''.join(
|
qualified_query = ''.join(
|
||||||
''.join(str(token) for token in schema_qualify(parsed_query))
|
''.join(str(token) for token in schema_qualify(parsed_query))
|
||||||
for parsed_query in sqlparse.parse(statement)
|
for parsed_query in sqlparse.parse(statement)
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qualified_query, statement.replace('testtable', 'public.testtable')
|
qualified_query,
|
||||||
|
statement.replace('testtable', 'public.testtable').replace(
|
||||||
|
'"public.testtable"', 'public."testtable"'
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user