Skip to content

Commit

Permalink
Fix warnings raised by incompatibilities with SQLAlchemy 2.x
Browse files Browse the repository at this point in the history
I believe this should mean we are compatible for the upgrade with this
library.
  • Loading branch information
Jon Betts committed Jan 11, 2023
1 parent 71bfa48 commit 5833ba5
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions .cookiecutter/includes/tox/setenv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SQLALCHEMY_WARN_20=1
5 changes: 1 addition & 4 deletions src/data_tasks/sql_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@ def execute(self, connection: Connection, dry_run=False, parameters=None):
"""Execute this query in the given session."""

with self.timing.time_it():
if not parameters:
parameters = {}

if dry_run:
return

cursor = connection.execute(sa.text(self.text), **parameters)
cursor = connection.execute(sa.text(self.text), parameters or {})
if cursor.returns_rows:
# pylint:disable=protected-access
self.columns = cursor._metadata.keys
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/data_tasks/sql_query_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ def assert_query_null_pre_execute(self, query):

@fixture
def connection(self, db_session):
with db_session.bind.connect() as connection:
yield connection
return db_session.bind

@fixture
def query(self):
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ setenv =
OBJC_DISABLE_INITIALIZE_FORK_SAFETY = YES
dev: DATABASE_URL = {env:DATABASE_URL:postgresql://postgres@localhost:5439/postgres}
tests,functests: TEST_DATABASE_URL = {env:TEST_DATABASE_URL:postgresql://postgres@localhost:5439/data_tasks_test}
SQLALCHEMY_WARN_20=1
passenv =
HOME
PYTEST_ADDOPTS
Expand Down

0 comments on commit 5833ba5

Please sign in to comment.