summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/elements.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-07-19 10:00:13 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2015-07-19 10:00:13 -0400
commit41aead96cdfd581c053a395992e1a3cf0b6a5572 (patch)
treefceafc25ac4ae48d181f5d34a45d5b49149e381e /lib/sqlalchemy/sql/elements.py
parent18a078654da286c0adf51a20a21398e357ed12ed (diff)
downloadsqlalchemy-41aead96cdfd581c053a395992e1a3cf0b6a5572.tar.gz
- Fixed potential issue where a custom subclass
of :class:`.FunctionElement` or other column element that incorrectly states 'None' or any other invalid object as the ``.type`` attribute will report this exception instead of recursion overflow. fixes #3485
Diffstat (limited to 'lib/sqlalchemy/sql/elements.py')
-rw-r--r--lib/sqlalchemy/sql/elements.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py
index 27ecce2b0..41dfcf147 100644
--- a/lib/sqlalchemy/sql/elements.py
+++ b/lib/sqlalchemy/sql/elements.py
@@ -715,7 +715,14 @@ class ColumnElement(operators.ColumnOperators, ClauseElement):
@util.memoized_property
def comparator(self):
- return self.type.comparator_factory(self)
+ try:
+ comparator_factory = self.type.comparator_factory
+ except AttributeError:
+ raise TypeError(
+ "Object %r associated with '.type' attribute "
+ "is not a TypeEngine class or object" % self.type)
+ else:
+ return comparator_factory(self)
def __getattr__(self, key):
try: