-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
db: adapt SopelDB to SQLAlchemy 2.x new style #2243
Conversation
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.
I realized that there are some unreviewed PRs, and also that I had the time to look at one.
Yeah, this one's good for a last round of review! |
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.
Wow, you went whole-hog on the Monty Python update! 😹 Since I don't quite know what I'd replace "SQLAlchemy ORM's mapping" with, let's leave it alone.
SQLAlchemy 1.4 (used by Sopel) defines a cross-compatible new style to query the database using its ORM, its engine, and its connection: * Engine cannot execute SQL directly * Connection can be used as context manager * Session can be used as context manager * Instead of doing *.query, use *.execute(stmt) * SQL statements are easier to create with select, update, and delete function from `sqlalchemy.sql` * And many other things One of the key change here is the usage of session object as context manager instead of using try/except block: less code, same feature! We can't set `future=True` on the Engine yet, because we need the non-compatible and now deprecated behavior of direct SQL execution from the Engine object: `SopelDB.execute` has been deprecated and should be removed in Sopel 8.1, so we can make Sopel compatible with both SQLAlchemy 1.4 and 2.0, as planned by SQLAlchemy migration strategy. In order to lower dgw's blood pressure, there are new tests, existing tests have been updated as well, and the coverage has increased from ~70% to ~85%. Also, more doc, because I always write more doc. Co-authored-by: dgw <dgw@technobabbl.es>
As noted by dgw, it's better to replace Sopel's owner/dev/users nicks by more neutral references to Monty Python characters and actors. Is that a dead parrot?
e25a4b1
to
d4189c2
Compare
Squashed! |
*stares in Klingon at @RustyBower* (not really to rush you, but to give a status update in-band since we've only talked about your ongoing review on IRC) |
@dgw all good now! |
I think you meant to ping @RustyBower for final thumbs-up, lol. This already got a ✔️ from me. 😁 |
Hm, I'm not sure we are going to get that review from @RustyBower. I'm pretty confident in my change in any case. |
Still LGTM :) |
Well the PR says "@RustyBower requested changes" so... 😁 |
Description
SQLAlchemy 1.4 (used by Sopel) defines a cross-compatible new style to query the database using its ORM, its engine, and its connection:
sqlalchemy.sql
One of the key change here is the usage of session object as context manager instead of using try/except block: less code, same feature!
We can't set
future=True
on the Engine yet, because we need the non-compatible and now deprecated behavior of direct SQL execution from the Engine object:SopelDB.execute
has been deprecated and should be removed in Sopel 8.1, so we can make Sopel compatible with both SQLAlchemy 1.4 and 2.0, as planned by SQLAlchemy migration strategy.In order to lower @dgw 's blood pressure, there are new tests, existing tests have been updated as well, and the coverage has increased from ~70% to ~85%.
Also, more doc, because I always write more doc.
PS: yes, some tests have been moved around to follow the same order of declaration as the method they are testing.
Checklist
make qa
(runsmake quality
andmake test
)