Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c302b2c

Browse filesBrowse files
jvanascozzzeek
authored andcommitted
migration note on subqueries
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. Added a note to the 2.0 migration guide. <!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once) --> This pull request is: - [x] 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!** Closes: #11107 Pull-request: #11107 Pull-request-sha: f8669da Change-Id: Id33779cb126a700d9adebe5f08f9d6c085589db4
1 parent 1178516 commit c302b2c
Copy full SHA for c302b2c

2 files changed

+34-1Lines changed: 34 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/build/Makefile‎

Copy file name to clipboardExpand all lines: doc/build/Makefile
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ PAPEROPT_letter = -D latex_paper_size=letter
1414
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
1515
# the i18n builder cannot share the environment and doctrees with the others
1616
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
17-
AUTOBUILDSPHINXOPTS = -T .
17+
AUTOBUILDSPHINXOPTS = -T -j auto .
1818

1919
.PHONY: help clean html autobuild dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest dist-html site-mako gettext
2020

Collapse file

‎doc/build/changelog/migration_20.rst‎

Copy file name to clipboardExpand all lines: doc/build/changelog/migration_20.rst
+33Lines changed: 33 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ The guide at :ref:`whatsnew_20_toplevel` provides an overview of
549549
new features and behaviors for SQLAlchemy 2.0 which extend beyond the base
550550
set of 1.4->2.0 API changes.
551551

552+
552553
2.0 Migration - Core Connection / Transaction
553554
---------------------------------------------
554555

@@ -2092,6 +2093,38 @@ when using an explicit :func:`_orm.aliased` object, both from a user point
20922093
of view as well as how the internals of the SQLAlchemy ORM must handle it.
20932094

20942095

2096+
Filtering with ``in_()``/``not_in()`` no longer accepts explicit subqueries
2097+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2098+
2099+
**Synopsis**
2100+
2101+
Support for accepting explicit subqueries in specific filtering operations, such
2102+
as :meth:`_sql.ColumnOperators.in_` and
2103+
:meth:`_sql.ColumnOperators.not_in`, has been removed in 2.0. The following
2104+
legacy usage will raise warnings and is incompatible with the type checking
2105+
system::
2106+
2107+
subq = (session.query(User.id).filter(User.name == "foo")).subquery()
2108+
q = session.query(User).filter(User.id.in_(subq))
2109+
2110+
**Migration to 2.0**
2111+
2112+
Under 2.0, SQLAlchemy will automatically interpret a fully constructed query
2113+
passed to :meth:`_sql.ColumnOperators.in_` and
2114+
:meth:`_sql.ColumnOperators.not_in` as a subquery based on the
2115+
implied context::
2116+
2117+
subq = select(User.id).filter(User.name == "foo")
2118+
stmt = session.execute(select(User).filter(User.id.in_(subq)))
2119+
2120+
**Partial Migration Notes**
2121+
2122+
A partial migration to 2.0 in which :class:`.orm.query.Query` is still utilized,
2123+
must be updated for compliance with the new API as well::
2124+
2125+
subq = session.query(User.id).filter(User.name == "foo")
2126+
q = session.query(User).filter(User.id.in_(subq))
2127+
20952128
.. _joinedload_not_uniqued:
20962129

20972130
ORM Rows not uniquified by default

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.