Conversation
|
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: mritter31.
|
5838031 to
f820dcd
Compare
mdesmet
left a comment
There was a problem hiding this comment.
Can you also add an integration test on the sqlalchemy beta version?
See
f820dcd to
063cc51
Compare
|
Thanks @mdesmet, that was what I was looking for. Unfortunately, the tests for 2.0 are failing because of an issue in |
063cc51 to
3b659f4
Compare
|
We're using that library only in tests if I remember correctly - can we remove that dependency with some alternative code? It's used in two tests - just to verify whether Would those tests still work if we directly executed |
3b659f4 to
704dae3
Compare
|
@hashhar They have just released a new version of |
b9b17b0 to
5934726
Compare
5e3fc8c to
d5a33aa
Compare
| """ | ||
| ).strip() | ||
| res = connection.execute(sql.text(query), schema=schema, table=table_name) | ||
| res = connection.execute(sql.text(query), {"schema": schema, "table": table_name}) |
There was a problem hiding this comment.
Is this change required for sqlalchemy 2.0.0?
There was a problem hiding this comment.
|
|
||
| if not engine.dialect.has_schema(conn, "test"): | ||
| engine.execute(sqla.schema.CreateSchema("test")) | ||
| with engine.begin() as connection: |
There was a problem hiding this comment.
Is this change required for sqlalchemy 2.0.0?
There was a problem hiding this comment.
1a3f263 to
701cc72
Compare
|
@hashhar : PTAL |
| metadata.create_all(engine) | ||
| view_name = schema_name + ".test_get_view_names" | ||
| conn.execute(f"CREATE VIEW {view_name} AS SELECT * FROM test_table") | ||
| conn.execute(sqla.text(f"CREATE VIEW {view_name} AS SELECT * FROM test_table")) |
There was a problem hiding this comment.
This conn object is a dbapi connection (see fixture trino_connection) so why do we need this sqla.text here?
There was a problem hiding this comment.
The conn object is a SQLAlchemy Connection instance:
trino-python-client/tests/integration/test_sqlalchemy_integration.py
Lines 20 to 25 in 701cc72
SQLAlchemy 2.0 requires this raw statement to be wrapped into text.
There was a problem hiding this comment.
Ah, 🤦 - should've seen what class the fixture is coming from. Thanks.
701cc72 to
a4ed553
Compare
|
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Mathias Ritter.
|
The following changes are for compatibility with SQLAlchemy 2.0, while mainting compatibility with versions >= 1.3. In the Connection.execute function, query parameters may no longer be passed as keyword arguments. Parameters can be passed in a dicionary instead. Engine.execute was removed. Statements can only be executed on the Connection object, which can be obtained via Engine.begin() or Engine.connect(). RowProxy is no longer a “proxy”; is now called Row and behaves like an enhanced named tuple. In order to access rows, just use row.column instead of row["column"]. Raw SQL statements must be wrapped into a TextClause by calling text(...), imported from sqlalchemy.
In the do_execute function of SQLAlchemy dialect, an if statement was accessing context.should_autocommit. This property has been removed in SQLAlchemy 2.0. To fix, the if statement can simply be removed as it is no longer needed.
a4ed553 to
5d80068
Compare
|
LGTM. @mathiasritter I assume you've sent the CLA already (and it matches the email you use in your commits)? If not please do. If sent already I'll take care of it. |
|
@hashhar Yes I’ve already sent it |
Description
In the do_execute function of SQLAlchemy dialect, an if statement was accessing context.should_autocommit. This property has been removed in SQLAlchemy 2.0.
To fix, the if statement can simply be removed as it is no longer needed. See #291 for more details.
Resolves #291
Non-technical explanation
The current dialect is incompatible with SQLAlchemy version 2.0. This change makes the dialect compatible.
Release notes
( ) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
(x) Release notes are required, with the following suggested text: