diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-09-21 17:28:03 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-09-21 19:55:59 -0400 |
commit | 0d1efeec475621b5c2c2aca0632b02edef54c1a6 (patch) | |
tree | be5b14aad521f8e41cd079c0e255087bbd04ea91 /lib/sqlalchemy/dialects/postgresql/asyncpg.py | |
parent | 73ab000007bd25ac86ca2081868615c6c4820531 (diff) | |
download | sqlalchemy-0d1efeec475621b5c2c2aca0632b02edef54c1a6.tar.gz |
Raise if unique() not applied to 2.0 joined eager load results
The automatic uniquing of rows on the client side is turned off for the new
:term:`2.0 style` of ORM querying. This improves both clarity and
performance. However, uniquing of rows on the client side is generally
necessary when using joined eager loading for collections, as there
will be duplicates of the primary entity for each element in the
collection because a join was used. This uniquing must now be manually
enabled and can be achieved using the new
:meth:`_engine.Result.unique` modifier. To avoid silent failure, the ORM
explicitly requires the method be called when the result of an ORM
query in 2.0 style makes use of joined load collections. The newer
:func:`_orm.selectinload` strategy is likely preferable for eager loading
of collections in any case.
This changeset also fixes an issue where ORM-style "single entity"
results would not apply unique() correctly if results were returned
as tuples.
Fixes: #4395
Change-Id: Ie62e0cb68ef2a6d2120e968b79575a70d057212e
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/asyncpg.py')
0 files changed, 0 insertions, 0 deletions