diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-12-11 19:01:12 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-12-11 22:01:57 -0500 |
commit | ed20e2f95f52a072d0c6b09af095b4cda0436d38 (patch) | |
tree | 340571f1d5bce61f5126a932a7739fee7efb3b77 /lib/sqlalchemy/sql/base.py | |
parent | 8e9e473dcb76b57a7f0eaa476481cb66a258ea69 (diff) | |
download | sqlalchemy-ed20e2f95f52a072d0c6b09af095b4cda0436d38.tar.gz |
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
Diffstat (limited to 'lib/sqlalchemy/sql/base.py')
-rw-r--r-- | lib/sqlalchemy/sql/base.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py index ff44ab27c..5178a7ab1 100644 --- a/lib/sqlalchemy/sql/base.py +++ b/lib/sqlalchemy/sql/base.py @@ -553,6 +553,14 @@ class _MetaOptions(type): def __add__(self, other): o1 = self() + + if set(other).difference(self._cache_attrs): + raise TypeError( + "dictionary contains attributes not covered by " + "Options class %s: %r" + % (self, set(other).difference(self._cache_attrs)) + ) + o1.__dict__.update(other) return o1 @@ -566,6 +574,14 @@ class Options(util.with_metaclass(_MetaOptions)): def __add__(self, other): o1 = self.__class__.__new__(self.__class__) o1.__dict__.update(self.__dict__) + + if set(other).difference(self._cache_attrs): + raise TypeError( + "dictionary contains attributes not covered by " + "Options class %s: %r" + % (self, set(other).difference(self._cache_attrs)) + ) + o1.__dict__.update(other) return o1 @@ -589,6 +605,10 @@ class Options(util.with_metaclass(_MetaOptions)): ), ) + @classmethod + def isinstance(cls, klass): + return issubclass(cls, klass) + @hybridmethod def add_to_element(self, name, value): return self + {name: getattr(self, name) + value} |