Sitelet https://github.com/sqlalchemy/sqlalchemy/pull/12988
Skip to content

Fix type hint for with_for_update() to support tuples of table classes - #12988

Closed
ashm-dev wants to merge 2 commits into
sqlalchemy:mainfrom
ashm-dev:gh-12730
Closed

ashm-dev wants to merge 2 commits into
sqlalchemy:mainfrom
ashm-dev:gh-12730

Conversation

@ashm-dev

@ashm-dev ashm-dev commented Nov 18, 2025 •

Copy link
Copy Markdown
Contributor

Fixes #12730

Description

Updated _ForUpdateOfArgument type alias to accept sequences of both column expressions and FROM clause arguments (tables, ORM entities). Previously only sequences of column expressions were supported, causing type checker errors when passing tuples of DeclarativeBase classes to with_for_update(of=...).

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!

Fixes sqlalchemy#12730

Updated _ForUpdateOfArgument type alias to accept sequences of both
column expressions and FROM clause arguments (tables, ORM entities).
Previously only sequences of column expressions were supported,
causing type checker errors when passing tuples of DeclarativeBase
classes to with_for_update(of=...).

@zzzeek zzzeek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hi -

this would benefit from a typing test in test/typing/plain_files/sql/common_sql_element.py, the original user case in the issue can be mostly copied in to make sure it raises no errors

@ashm-dev
ashm-dev requested a review from zzzeek November 19, 2025 06:43
@zzzeek
zzzeek requested a review from sqla-tester November 19, 2025 13:02

@sqla-tester sqla-tester left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

OK, this is sqla-tester setting up my work on behalf of zzzeek to try to get revision 41a38bf of this pull request into gerrit so we can run tests and reviews and stuff

@sqla-tester

Copy link
Copy Markdown
Collaborator

New Gerrit review created for change 41a38bf: https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/6438

@sqla-tester

Copy link
Copy Markdown
Collaborator

Gerrit review https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/6438 has been merged. Congratulations! :)

@sqla-tester

Copy link
Copy Markdown
Collaborator

Gerrit review https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/6439 has been merged. Congratulations! :)

sqlalchemy-bot pushed a commit that referenced this pull request Nov 19, 2025
Fixed typing issue where :meth:`.Select.with_for_update` would not support
lists of ORM entities in the :paramref:`.Select.with_for_update.of`
parameter. Pull request courtesy Shamil.

Fixes: #12730
Closes: #12988
Pull-request: #12988
Pull-request-sha: 41a38bf

Change-Id: I61d60a4f4d2b16037da8d5f30e33f5d74fa47374
(cherry picked from commit a057c47)
@ashm-dev
ashm-dev deleted the gh-12730 branch November 19, 2025 20:07

@sqla-tester sqla-tester left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Federico Caselli (CaselIT) wrote:

code review left on gerrit

View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/6438

  • doc/build/changelog/unreleased_20/12730.rst (line 5): we do changelogs for typing changes now?

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.

Passing multiple tables to with_for_update() typing issue.

3 participants