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

migration note on subqueries #11107

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jvanasco
Copy link
Member

@jvanasco jvanasco commented Mar 5, 2024

Change-Id: Id33779cb126a700d9adebe5f08f9d6c085589db4

Under 2.0, calls to in_ and not_in no longer accept an explicit .subquery().

Passing a .subquery() will cause typing issues from MyPy AND will raise runtime warnings.

There was no note of this in the migration guide. This may be an effect of another change that is disclosed in the migration guide. If so, I suggest nesting this text (or improved text describing this) under that section for ease in discovery and migration.

Description

Added a note to the 2.0 migration guide.

Checklist

This pull request is:

  • A documentation / typographical / small typing error fix
    • Good to go, no issue or tests are needed
  • A short code fix
    • please include the issue number, and create an issue if none exists, which
      must include a complete example of the issue. one line code fixes without an
      issue and demonstration will not be accepted.
    • Please include: Fixes: #<issue number> in the commit message
    • please include tests. one line code fixes without tests will not be accepted.
  • A new feature implementation
    • please include the issue number, and create an issue if none exists, which must
      include a complete example of how the feature would look.
    • Please include: Fixes: #<issue number> in the commit message
    • please include tests.

Have a nice day!

Change-Id: Id33779cb126a700d9adebe5f08f9d6c085589db4
Copy link
Member

@zzzeek zzzeek left a comment

Choose a reason for hiding this comment

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

the migration to 2.0 is still using session.query() so is not fully migrated

as a subquery based on the implied context ::

subq = (
session.query(User.id)
Copy link
Member

Choose a reason for hiding this comment

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

for migration to 2.0 the select() construct, not session.query(), should be used. with select(), you'd want to call subquery() on that unless you are using it inside of in_(). so this note should also mention that this is specific to in_()/not_in()

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm going to move stuff around and incorporate your info. I'll use github for a bit and try to avoid gerrit if you don't mind.

Copy link
Member Author

Choose a reason for hiding this comment

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

I waited a bit before revisiting, and think this is the approach. Ready for review.

Change-Id: I1745aa960acd99e00e7504e23fba7cd504e74f72
@jvanasco jvanasco requested a review from zzzeek March 29, 2024 20:30
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.

None yet

2 participants