Skip to content

Conversation

@mdesmet
Copy link
Contributor

@mdesmet mdesmet commented Oct 10, 2022

Fixes #250

Description

scalar_one() and scalar_one_or_none() are not available in sqlalchemy 1.3. They have been replaced by scalar() calls.

sqlalchemy has also been added into the ci matrix to ensure compatibility with 1.3 and 1.4 versions.

Non-technical explanation

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:

* Use sqlalchemy 1.3 compatible methods in sqlalchemy dialect.

@cla-bot cla-bot bot added the cla-signed label Oct 10, 2022
@mdesmet mdesmet force-pushed the bug/sqlalchemy-matrix branch 2 times, most recently from e112407 to 877f865 Compare October 10, 2022 11:21
Copy link
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems to be an unfortunate situation since we're adding a matrix but also removing most of the tests.

How do other clients provide support for multiple SQLAlchemy versions?

sudo apt-get update
sudo apt-get install libkrb5-dev
pip install .[tests]
pip install .[tests] sqlalchemy~=${{ matrix.sqlalchemy }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd instead say to inline the constraint in the matrix entry itself.

i.e. ~=1.4.0 (latest 1.4)
==1.4.2 (some specific version)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense!

Comment on lines +79 to +82
@pytest.mark.skipif(
sqlalchemy_version() < "1.4",
reason="columns argument to select() must be a Python list or other iterable"
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're basically dropping lot of coverage. Seems like to make sure we can reasonably rely on the matrix we'd need to create two test classes or modify tests to work with both.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed but I suggest we do that as a follow up issue. Most test cases are basically sqlalchemy feature tests. In this fix we mainly lay the foundation (the test matrix) and fix the issue at hand: #250

),
),
],
] if sqlalchemy_version() >= "1.4" else [], # make_url is not supported in sqlalchemy 1.3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do docs need updating as well that the URL static helper can only be used with 1.4.x?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I fixed it now by adding a slash after the port. So now the helper is working for 1.3 and 1.4.

@mdesmet mdesmet force-pushed the bug/sqlalchemy-matrix branch from 877f865 to b48d1e1 Compare October 10, 2022 12:07
@hovaesco
Copy link
Member

Let's create a compatibility section under https://github.com/trinodb/trino-python-client#sqlalchemy and document which SQLAlchemy versions are supported.

@mdesmet mdesmet force-pushed the bug/sqlalchemy-matrix branch from b48d1e1 to 9ed85b1 Compare October 10, 2022 12:11
@mdesmet
Copy link
Contributor Author

mdesmet commented Oct 10, 2022

Let's create a compatibility section under https://github.com/trinodb/trino-python-client#sqlalchemy and document which SQLAlchemy versions are supported.

Let's handle this as follow up.

@mdesmet
Copy link
Contributor Author

mdesmet commented Oct 10, 2022

@hashhar, @hovaesco: My point is that both 1.3 and 1.4 are supported but there will be some rough edges which will only surfaced by adding more integration tests.

I have added the compatibility section though.

@hashhar hashhar merged commit 59473d7 into trinodb:master Oct 11, 2022
@mdesmet mdesmet deleted the bug/sqlalchemy-matrix branch October 11, 2022 09:36
@john-bodley
Copy link
Contributor

john-bodley commented Oct 19, 2022

@mdesmet what's wrong with simply adding a dependency constraint that only SQLAlchemy >= 1.4 is supported? This adheres to the KISS principle and doesn't pollute the code, unit tests, CI build matrix etc.

@hashhar
Copy link
Member

hashhar commented Oct 27, 2022

Because we can't control what other third party tools use as the version of SQLAlchemy.

I'd love to be able to force a version of SQLAlchemy on the consumer to simply our lives but it's not possible today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

Trino 0.317 broke compatibility with SQLAlchemy 1.3.24

4 participants