Skip to content
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

Add support to SQLAlchemy 2.x #97

Merged
merged 3 commits into from
Oct 18, 2023

Conversation

aemitos
Copy link
Contributor

@aemitos aemitos commented Oct 6, 2023

Summary

This PR upgrade packages using the dependency resolution from poetry.
No changes were applied to the package code.
Tests were reviewed and adjusted to be compatible with the SQLAlchemy 2.x.

Tests are passing:
Screenshot 2023-10-02 at 6 49 59 PM

Here are the changes applied to support the tSQLAlchemy >=2.x:

  • upgrade dependencies to support SQLAlchemy 2.x and fix call.
  • update call for the SQLAlchemy 2.x
  • upgrade black and flake8
  • black and flake8 check

Previous PRs logged: #95 and #96

Here are the changes applied to support the tSQLAlchemy >=2.x:
* black and flake8 check
* upgrade black and flake8
* update call for the SQLAlchemy 2.x
* upgrade dependencies to support SQLAlchemy 2.x and fix call.
@aemitos
Copy link
Contributor Author

aemitos commented Oct 6, 2023

Hi @siddhantgoel
This one should be good to go!
Thanks!

Comment on lines -63 to +72
foo_count = (
db.get_engine('foo')
.execute("SELECT COUNT(*) FROM foo")
.fetchone()[0]
)
bar_count = (
db.get_engine('bar')
.execute("SELECT COUNT(*) FROM bar")
.fetchone()[0]
)
with db.get_engine('foo').begin() as conn:
foo_count = conn.execute(
text("SELECT COUNT(*) FROM foo")
).fetchone()[0]

with db.get_engine('bar').begin() as conn:
bar_count = conn.execute(
text("SELECT COUNT(*) FROM bar")
).fetchone()[0]
Copy link
Owner

Choose a reason for hiding this comment

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

Just for me to understand this correctly, if we don't introduce this change in the test, then the test would fail in case SQLAlchemy 1.x is installed? Or is this how the call is made in the latest 1.x release?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is how the call should be written in 2.x.

Copy link
Owner

Choose a reason for hiding this comment

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

Hmm, in that case we'll need to write some compatibility code inside the main library. Otherwise we'll be breaking usage for 1.x users.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point. I'm checking the https://docs.sqlalchemy.org/en/20/changelog/migration_20.html#first-prerequisite-step-two-a-working-1-4-application to identify changes. Let me test it with the last 1.4 version.

Copy link
Contributor Author

@aemitos aemitos Oct 9, 2023

Choose a reason for hiding this comment

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

The tests passed with 1.4.49.
Screenshot 2023-10-09 at 9 46 15 AM

Copy link
Owner

Choose a reason for hiding this comment

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

Awesome, thanks for looking it up. In that case we should probably specify something like SQLAlchemy >= 1.4 or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added on 109c2ab

pyproject.toml Show resolved Hide resolved
Co-authored-by: Siddhant Goel <[email protected]>
@aemitos
Copy link
Contributor Author

aemitos commented Oct 13, 2023

Hi @siddhantgoel
I replied to your feedback in last PR review.
Let me know how we can get this on to completion.
Thanks!

@siddhantgoel
Copy link
Owner

Hey, thanks for pushing the changes. I left one comment and the CI is complaining about something that we should fix before we can merge it in!

SQLAlchemy >= 1.4 and Python 3.8.1 for Flake8.
@siddhantgoel siddhantgoel merged commit 75e79c0 into siddhantgoel:main Oct 18, 2023
4 checks passed
@siddhantgoel
Copy link
Owner

I just published v0.8.0 which should include this fix.

The only change I had to make was to adjust the dependency string slightly (replace SQLAlchemy = ^1.4 with SQLAlchemy = "^1.4 || ^2.0") such that 2.x is also allowed.

@aemitos
Copy link
Contributor Author

aemitos commented Oct 25, 2023

I just published v0.8.0 which should include this fix.

The only change I had to make was to adjust the dependency string slightly (replace SQLAlchemy = ^1.4 with SQLAlchemy = "^1.4 || ^2.0") such that 2.x is also allowed.

Awesome, thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants