-
Notifications
You must be signed in to change notification settings - Fork 106
[Issue 171] Improve sqlalchemy dialect backward compatibility with 1.3.24 #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
catalog, and schema must instead be passed as connect_args. This change allows our e2e tests to run. But they won't pass yet. Signed-off-by: Jesse Whitehouse <[email protected]>
…that Databricks doesn't support. This default is changed in versions > 1.4 https: //docs.sqlalchemy.org/en/20/changelog/migration_14.html#enum-and-boolean-datatypes-no-longer-default-to-create-constraint Signed-off-by: Jesse Whitehouse <[email protected]>
different property names than SQLAlchemy > 1.4. So here I wrapped the logic in a public method. Signed-off-by: Jesse Whitehouse <[email protected]>
method https: //docs.sqlalchemy.org/en/20/changelog/migration_14.html#orm-query-is-internally-unified-with-select-update-delete-2-0-style-execution-available Signed-off-by: Jesse Whitehouse <[email protected]>
… earlier versions Signed-off-by: Jesse Whitehouse <[email protected]>
Use samples catalog to avoid flakiness on our internal infrastructure Signed-off-by: Jesse Whitehouse <[email protected]>
self.catalog if the version is < 1.4. This means that you _must_ use the new connection string format for >= 1.4 Signed-off-by: Jesse Whitehouse <[email protected]>
Signed-off-by: Jesse Whitehouse <[email protected]>
Signed-off-by: Jesse Whitehouse <[email protected]>
Signed-off-by: Jesse Whitehouse <[email protected]>
@@ -237,7 +238,11 @@ class SampleObject(base): | |||
SampleObject.name.in_(["Bim Adewunmi", "Miki Meek"]) | |||
) | |||
|
|||
output = [i for i in session.scalars(stmt)] | |||
if sqlalchemy_1_3(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops. This change belongs in a separate commit. Basically: version 1.3 doesn't have the .scalars
method whereas 1.4 does.
Signed-off-by: Jesse Whitehouse <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appreciate the detailed walkthrough with the commit messages!
Signed-off-by: Jesse Whitehouse <[email protected]>
Description
In #113 we relaxed the version requirement for SQLAlchemy. But some changes are needed to the client code to actually work with version 1.3. This wasn't caught in our e2e tests initially because our test infra installs the newest supported version of SQLAlchemy -- so the tests never actually ran under
1.3.24
.This pull request is split into easily understood commits that make sense to review one-by-one. Here are the changes needed to backport 1.3 support:
http_path
,catalog
, andschema
in your extraconnect_args
not in the connection string. This pull request reflects that change inexamples/sqlalchemy.py
and our test suite.databricks-sql-connector
'sget_columns
andget_tables
methods.select()
construct (changelog). That change is not backwards compatible. So I added conditional logic in our tests and example script.Inspector
object for reflection. I added a smoke test to ensure that this works in a basic use-case. This pull request does not implement a comprehensive suite of tests. More changes may be needed. We will expect further feedback from users on older versions of SQLAlchemy.Related Tickets & Documents
Closes #171
Follow-up for #113
Tests
I ran the e2e tests with SQLAlchemy 1.4.48 and 1.3.24. All tests now pass. I also ran
examples/sqlalchemy.py
under both installations to confirm it works.To test this yourself, check out this branch and run
poetry install
. Then runpoetry run pip install sqlalchemy==1.3.24
to force the SQLAlchemy version back to 1.3. Then just run the sqlalchemy e2e tests.You can also run
pip install databricks-sql-connector==2.7.1.dev1
and run theexamples/sqlalchemy.py
script from a fresh virtualenv to ensure that it works for you.1.3.24
1.4.48
Prior to this change, version 1.3.24 would error-out immediately.