]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Fix with_expression() cache leak; don't adapt singletons
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 14 Apr 2021 22:53:25 +0000 (18:53 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 14 Apr 2021 23:41:02 +0000 (19:41 -0400)
commit60b0a693c97e7ab504a0d36497b71ccba24ac8e8
treebd5fe1486ed8b50e4f2dba966bd3bbc16c5eee8f
parentcee6d12a69af38915316d6db8ca59c54325904ea
Fix with_expression() cache leak; don't adapt singletons

Fixed a cache leak involving the :func:`_orm.with_expression` loader
option, where the given SQL expression would not be correctly considered as
part of the cache key.

Additionally, fixed regression involving the corresponding
:func:`_orm.query_expression` feature. While the bug technically exists in
1.3 as well, it was not exposed until 1.4. The "default expr" value of
``null()`` would be rendered when not needed, and additionally was also not
adapted correctly when the ORM rewrites statements such as when using
joined eager loading. The fix ensures "singleton" expressions like ``NULL``
and ``true`` aren't "adapted" to refer to columns in ORM statements, and
additionally ensures that a :func:`_orm.query_expression` with no default
expression doesn't render in the statement if a
:func:`_orm.with_expression` isn't used.

Fixes: #6259
Change-Id: I5a70bc12dadad125bbc4324b64048c8d4a18916c
doc/build/changelog/unreleased_14/6259.rst [new file with mode: 0644]
lib/sqlalchemy/orm/strategies.py
lib/sqlalchemy/orm/strategy_options.py
lib/sqlalchemy/sql/base.py
lib/sqlalchemy/sql/util.py
test/orm/test_cache_key.py
test/orm/test_core_compilation.py
test/orm/test_deferred.py
test/sql/test_external_traversal.py