From ed20e2f95f52a072d0c6b09af095b4cda0436d38 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 11 Dec 2020 19:01:12 -0500 Subject: Fixes for lambda expressions and relationship loaders Fixed bug in lambda SQL feature, used by ORM :meth:`_orm.with_loader_criteria` as well as available generally in the SQL expression language, where assigning a boolean value True/False to a variable would cause the query-time expression calculation to fail, as it would produce a SQL expression not compatible with a bound value. Fixed issue where the :attr:`_orm.ORMExecuteState.is_relationship_load` parameter would not be set correctly for many lazy loads, all selectinloads, etc. The flag is essential in order to test if options should be added to statements or if they would already have been propagated via relationship loads. Fixes: #5763 Fixes: #5764 Change-Id: I66aafbef193f892ff75ede0670698647b7475482 --- lib/sqlalchemy/sql/lambdas.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/sql/lambdas.py') diff --git a/lib/sqlalchemy/sql/lambdas.py b/lib/sqlalchemy/sql/lambdas.py index 676152781..aafdda4ce 100644 --- a/lib/sqlalchemy/sql/lambdas.py +++ b/lib/sqlalchemy/sql/lambdas.py @@ -1021,7 +1021,12 @@ class PyWrapper(ColumnOperators): def __getattribute__(self, key): if key.startswith("_sa_"): return object.__getattribute__(self, key[4:]) - elif key in ("__clause_element__", "operate", "reverse_operate"): + elif key in ( + "__clause_element__", + "operate", + "reverse_operate", + "__class__", + ): return object.__getattribute__(self, key) if key.startswith("__"): -- cgit v1.2.1