diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2021-07-20 19:19:26 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2021-07-20 19:19:26 +0000 |
commit | e7119aea7870f0322e78d3a2cb28337b1640f0c2 (patch) | |
tree | 021a176797ba2efbf27f1dc7e1ca3f3ba22dd179 /lib/sqlalchemy | |
parent | e72106d1499ec628487f7e428e7c49acdd4eb9c0 (diff) | |
parent | 85fa3473be1332af34ce905e9ea0affdeefbb223 (diff) | |
download | sqlalchemy-e7119aea7870f0322e78d3a2cb28337b1640f0c2.tar.gz |
Merge "Documentation improvements"
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r-- | lib/sqlalchemy/engine/result.py | 9 | ||||
-rw-r--r-- | lib/sqlalchemy/ext/asyncio/result.py | 9 | ||||
-rw-r--r-- | lib/sqlalchemy/orm/strategy_options.py | 10 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/elements.py | 2 |
4 files changed, 24 insertions, 6 deletions
diff --git a/lib/sqlalchemy/engine/result.py b/lib/sqlalchemy/engine/result.py index 119bf4a9e..60474c0ed 100644 --- a/lib/sqlalchemy/engine/result.py +++ b/lib/sqlalchemy/engine/result.py @@ -708,6 +708,15 @@ class Result(_WithKeys, ResultInternal): :class:`.ResultProxy` interface. When using the ORM, a higher level object called :class:`.ChunkedIteratorResult` is normally used. + .. note:: In SQLAlchemy 1.4 and above, this object is + used for ORM results returned by :meth:`_orm.Session.execute`, which can + yield instances of ORM mapped objects either individually or within + tuple-like rows. Note that the :class:`_result.Result` object does not + deduplicate instances or rows automatically as is the case with the + legacy :class:`_orm.Query` object. For in-Python de-duplication of + instances or rows, use the :meth:`_result.Result.unique` modifier + method. + .. seealso:: :ref:`tutorial_fetching_rows` - in the :doc:`/tutorial/index` diff --git a/lib/sqlalchemy/ext/asyncio/result.py b/lib/sqlalchemy/ext/asyncio/result.py index 2fdaec741..dff87a569 100644 --- a/lib/sqlalchemy/ext/asyncio/result.py +++ b/lib/sqlalchemy/ext/asyncio/result.py @@ -29,6 +29,15 @@ class AsyncResult(AsyncCommon): :meth:`_asyncio.AsyncConnection.stream` and :meth:`_asyncio.AsyncSession.stream` methods. + .. note:: As is the case with :class:`_engine.Result`, this object is + used for ORM results returned by :meth:`_asyncio.AsyncSession.execute`, + which can yield instances of ORM mapped objects either individually or + within tuple-like rows. Note that these result objects do not + deduplicate instances or rows automatically as is the case with the + legacy :class:`_orm.Query` object. For in-Python de-duplication of + instances or rows, use the :meth:`_asyncio.AsyncResult.unique` modifier + method. + .. versionadded:: 1.4 """ diff --git a/lib/sqlalchemy/orm/strategy_options.py b/lib/sqlalchemy/orm/strategy_options.py index 043ecfed3..399e33b89 100644 --- a/lib/sqlalchemy/orm/strategy_options.py +++ b/lib/sqlalchemy/orm/strategy_options.py @@ -414,7 +414,7 @@ class Load(Generative, LoaderOption): query = session.query(Author) query = query.options( joinedload(Author.book).options( - load_only("summary", "excerpt"), + load_only(Book.summary, Book.excerpt), joinedload(Book.citations).options( joinedload(Citation.author) ) @@ -1152,14 +1152,14 @@ def load_only(loadopt, *attrs): Example - given a class ``User``, load only the ``name`` and ``fullname`` attributes:: - session.query(User).options(load_only("name", "fullname")) + session.query(User).options(load_only(User.name, User.fullname)) Example - given a relationship ``User.addresses -> Address``, specify subquery loading for the ``User.addresses`` collection, but on each ``Address`` object load only the ``email_address`` attribute:: session.query(User).options( - subqueryload("addresses").load_only("email_address") + subqueryload(User.addresses).load_only(Address.email_address) ) For a :class:`_query.Query` that has multiple entities, @@ -1167,8 +1167,8 @@ def load_only(loadopt, *attrs): specifically referred to using the :class:`_orm.Load` constructor:: session.query(User, Address).join(User.addresses).options( - Load(User).load_only("name", "fullname"), - Load(Address).load_only("email_address") + Load(User).load_only(User.name, User.fullname), + Load(Address).load_only(Address.email_address) ) .. note:: This method will still load a :class:`_schema.Column` even diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index e253ddb93..f519c1b3e 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -2835,7 +2835,7 @@ class Case(ColumnElement): stmt = select(users_table).\ where( case( - whens={"wendy": "W", "jack": "J"}, + {"wendy": "W", "jack": "J"}, value=users_table.c.name, else_='E' ) |