summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2017-04-04 09:06:13 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2017-04-04 09:06:13 -0400
commitd13734add349ec6763cce8b194806c5afe988000 (patch)
treef2083413bc8332953169dd38b3ec1f99ad21d389
parent9609f5ffb52ce8a4969059e299773ac7176dbb0d (diff)
downloadsqlalchemy-d13734add349ec6763cce8b194806c5afe988000.tar.gz
Ensure we check that SQL expression has an .info attribute
Fixed regression released in 1.1.8 due to :ticket:`3950` where the deeper search for information about column types in the case of a "schema type" or a :class:`.TypeDecorator` would produce an attribute error if the mapping also contained a :obj:`.column_property`. Change-Id: I38254834d3d79c9b339289a8163eb4789ec4c931 Fixes: #3956
-rw-r--r--doc/build/changelog/changelog_11.rst9
-rw-r--r--lib/sqlalchemy/ext/mutable.py3
-rw-r--r--test/ext/test_mutable.py6
3 files changed, 15 insertions, 3 deletions
diff --git a/doc/build/changelog/changelog_11.rst b/doc/build/changelog/changelog_11.rst
index 3a5b29dec..f4b782093 100644
--- a/doc/build/changelog/changelog_11.rst
+++ b/doc/build/changelog/changelog_11.rst
@@ -21,6 +21,15 @@
.. changelog::
:version: 1.1.9
+ .. change:: 3956
+ :tags: bug, ext
+ :tickets: 3956
+
+ Fixed regression released in 1.1.8 due to :ticket:`3950` where the
+ deeper search for information about column types in the case of a
+ "schema type" or a :class:`.TypeDecorator` would produce an attribute
+ error if the mapping also contained a :obj:`.column_property`.
+
.. change:: 3952
:tags: bug, sql
:versions: 1.2.0b1
diff --git a/lib/sqlalchemy/ext/mutable.py b/lib/sqlalchemy/ext/mutable.py
index a133f950d..e721397b3 100644
--- a/lib/sqlalchemy/ext/mutable.py
+++ b/lib/sqlalchemy/ext/mutable.py
@@ -600,7 +600,8 @@ class Mutable(MutableBase):
for prop in mapper.column_attrs:
if (
schema_event_check and
- prop.columns[0].info.get('_ext_mutable_orig_type')
+ hasattr(prop.expression, 'info') and
+ prop.expression.info.get('_ext_mutable_orig_type')
is sqltype
) or (
prop.columns[0].type is sqltype
diff --git a/test/ext/test_mutable.py b/test/ext/test_mutable.py
index 5b6d3e7cf..23bccafe9 100644
--- a/test/ext/test_mutable.py
+++ b/test/ext/test_mutable.py
@@ -1,6 +1,6 @@
-from sqlalchemy import Integer, ForeignKey, String
+from sqlalchemy import Integer, ForeignKey, String, func
from sqlalchemy.types import PickleType, TypeDecorator, VARCHAR
-from sqlalchemy.orm import mapper, Session, composite
+from sqlalchemy.orm import mapper, Session, composite, column_property
from sqlalchemy.orm.mapper import Mapper
from sqlalchemy.orm.instrumentation import ClassManager
from sqlalchemy.testing.schema import Table, Column
@@ -761,6 +761,8 @@ class MutableColumnCopyJSONTest(_MutableDictTestBase, fixtures.MappedTest):
class Foo(AbstractFoo):
__tablename__ = "foo"
+ column_prop = column_property(
+ func.lower(AbstractFoo.unrelated_data))
assert Foo.data.property.columns[0].type is not AbstractFoo.data.type