summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r--lib/sqlalchemy/sql/base.py20
-rw-r--r--lib/sqlalchemy/sql/lambdas.py7
2 files changed, 26 insertions, 1 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}
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("__"):