-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Sqlalchemy 2.0 changes for test_scheduler_job.py #59823
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
Sqlalchemy 2.0 changes for test_scheduler_job.py #59823
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.
Pull request overview
This PR migrates test_scheduler_job.py to SQLAlchemy 2.0 syntax by replacing legacy .query() API calls with the modern select() construct. The changes remove deprecated SQLAlchemy 1.4 compatibility code and align with SQLAlchemy 2.0 best practices.
Key changes:
- Replaced
.query().filter()patterns withsession.scalars(select().where())for retrieving objects - Replaced
.query().filter().scalar()withsession.scalar(select().where())for scalar values - Updated count operations from
.query().count()tolen(session.scalars(select()).all())orsession.scalar(select(func.count())) - Removed imports and conditional logic for
SQLALCHEMY_V_1_4andSQLALCHEMY_V_2_0version checks
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| airflow-core/tests/unit/jobs/test_scheduler_job.py | Migrated all SQLAlchemy query operations from legacy .query() API to 2.0-style select() constructs, removed version compatibility code, and added proper .unique() calls for joinedload queries |
| .pre-commit-config.yaml | Added test_scheduler_job.py to the list of files checked by pre-commit hooks |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
shahar1
left a comment
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.
Could you please address issues raised by Copilot?
yeah I will get to these over the weekend |
Prab-27
left a comment
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.
Looks good to me, great work!
|
Nice :) Thanks! |
Backport failed to create: v3-1-test. View the failure log Run details
You can attempt to backport this manually by running: cherry_picker bd8e0d3 v3-1-testThis should apply the commit to the v3-1-test branch and leave the commit in conflict state marking After you have resolved the conflicts, you can continue the backport process by running: cherry_picker --continue |
* Compatibility updates for sqlalchemy 2.0 * Fixes for review comments * Fixes for review comments * More fixes for review comments
* Compatibility updates for sqlalchemy 2.0 * Fixes for review comments * Fixes for review comments * More fixes for review comments
* Compatibility updates for sqlalchemy 2.0 * Fixes for review comments * Fixes for review comments * More fixes for review comments
* Compatibility updates for sqlalchemy 2.0 * Fixes for review comments * Fixes for review comments * More fixes for review comments
Issue description: #59402
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.