Refactor sqlalchemy queries to 2.0 style (Part 1) #31569
Merged
Merged
Conversation
ephraimbuddy
force-pushed
the
sqlalchemy-20-query-style
branch
8 times, most recently
from
May 28, 2023 11:55
ec72e1e to
0994ff2
Compare
ephraimbuddy
marked this pull request as ready for review
May 28, 2023 11:56
ephraimbuddy
requested review from
XD-DENG,
ashb,
bbovenzi,
dstandish,
jedcunningham,
kaxil,
pierrejeambrun,
potiuk and
ryanahamilton
as code owners
May 28, 2023 11:56
ephraimbuddy
force-pushed
the
sqlalchemy-20-query-style
branch
2 times, most recently
from
May 28, 2023 13:55
872d853 to
334ebeb
Compare
uranusjr
reviewed
May 29, 2023
uranusjr
reviewed
May 29, 2023
Comment on lines
466
to
475
Member
There was a problem hiding this comment.
Note: This can be rewritten with scalars on TaskInstance.task_id instead. (Maybe in a later PR.)
uranusjr
reviewed
May 29, 2023
uranusjr
reviewed
May 29, 2023
uranusjr
reviewed
May 29, 2023
uranusjr
reviewed
May 29, 2023
uranusjr
reviewed
May 29, 2023
uranusjr
reviewed
May 29, 2023
ephraimbuddy
force-pushed
the
sqlalchemy-20-query-style
branch
from
May 29, 2023 09:04
46e0043 to
6708ec9
Compare
uranusjr
reviewed
May 29, 2023
uranusjr
reviewed
May 29, 2023
Member
There was a problem hiding this comment.
Hmm, it’s weird these screenshots are being updated. The added colouring also is suspective.
Contributor
Author
There was a problem hiding this comment.
I ran breeze setup regenerate-command-images --force when I couldn't find why the PR was failing on pre-commit generating ER diagram(not locally)
Member
There was a problem hiding this comment.
Yes, what I was trying to say is I don’t understand why pre-commit thinks they need to be updated at all.
ephraimbuddy
force-pushed
the
sqlalchemy-20-query-style
branch
from
May 29, 2023 13:21
f369550 to
6722b44
Compare
uranusjr
reviewed
May 30, 2023
uranusjr
reviewed
May 30, 2023
Comment on lines
361
to
363
Member
There was a problem hiding this comment.
Should be equivalent to
Suggested change
| dag_run = session.execute( | |
| select(DagRun).where(DagRun.dag_id == dag_id, DagRun.run_id == run_id) | |
| ).scalar_one() | |
| dag_run = session.scalars( | |
| select(DagRun).where(DagRun.dag_id == dag_id, DagRun.run_id == run_id) | |
| ).one() |
but I don’t think this is better. So just for reference in case anyone wonders.
uranusjr
approved these changes
May 30, 2023
This commit updates the sqlalchemy queries to adopt the 2.0 query style, which is compatible with version 1.4. The changes involve updating the engine with the future=True flag to indicate the execution of queries using the 2.0 style. As a result, textual SQL statements are wrapped with the text function. In addition, queries that previously used delete and update operations have been modified to utilize the new delete/update construct. Furthermore, all queries within the jobs/ and api/ directories have been thoroughly updated to employ the new style queries. Please note that this commit intentionally stops at this point to ensure ease of review for the pull request. The only test change is the addition of the future flag to the create_engine function.
Co-authored-by: Tzu-ping Chung <[email protected]>
ephraimbuddy
force-pushed
the
sqlalchemy-20-query-style
branch
from
May 30, 2023 06:23
6722b44 to
c64be9f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit updates the sqlalchemy queries to adopt the 2.0 query style,
which is compatible with version 1.4. The changes involve updating the engine
with the future=True flag to indicate the execution of queries using the 2.0 style.
As a result, textual SQL statements are wrapped with the text function.
In addition, queries that previously used delete and update operations have been
modified to utilize the new delete/update construct. Furthermore, all queries within the
jobs/ and api/ directories have been thoroughly updated to employ the new style queries.
Please note that this commit intentionally stops at this point to ensure ease of review for the pull request.
The only test change is the addition of the future flag to the create_engine function.