Skip to content

Commit

Permalink
fixed problem with _is_valid_sql (#542)
Browse files Browse the repository at this point in the history
* fixed problem with _is_valid_sql

* sloppy..

---------

Co-authored-by: Barry Daniels <[email protected]>
  • Loading branch information
barrydaniels-nl and gurustacks authored Jan 25, 2024
1 parent d47a61a commit b5c783f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2024-01-25 (5.23.3)

* Fix in _is_valid_sql to fix materialized view problem.

# 2024-01-23 (5.23.2)

* Fix to the _get_scopes to return the correct scopes for both dataset, table
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = amsterdam-schema-tools
version = 5.23.2
version = 5.23.3
url = https://github.com/amsterdam/schema-tools
license = Mozilla Public 2.0
author = Team Data Diensten, van het Dataplatform onder de Directie Digitale Voorzieningen (Gemeente Amsterdam)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,7 @@ def _is_valid_sql(view_sql: str, view_name: str, write_role_name: str) -> bool:
with transaction.atomic():
sid = transaction.savepoint()
with connection.cursor() as cursor:

# Check if write role exists and create if it does not
_create_role_if_not_exists(cursor, write_role_name)

cursor.execute(
sql.SQL("SET ROLE {write_role_name}").format(
write_role_name=sql.Identifier(write_role_name)
)
)

cursor.execute('SET statement_timeout = 5000;')
cursor.execute(view_sql)
transaction.savepoint_rollback(sid)
except Exception as e: # noqa: F841
Expand All @@ -44,7 +35,6 @@ def _is_valid_sql(view_sql: str, view_name: str, write_role_name: str) -> bool:
def _get_scopes(datasetname: str, tablename: str) -> frozenset[str]:
from functools import reduce
from operator import __or__

dataset = DATASETS.get(name=to_snake_case(datasetname)).schema
if tablename in [table.id for table in dataset.tables]:
table = dataset.get_table_by_id(tablename)
Expand Down

0 comments on commit b5c783f

Please sign in to comment.