From: Mike Bayer Date: Tue, 4 Apr 2017 13:06:13 +0000 (-0400) Subject: Ensure we check that SQL expression has an .info attribute X-Git-Tag: rel_1_2_0b1~116^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d13734add349ec6763cce8b194806c5afe988000;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git 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 --- diff --git a/doc/build/changelog/changelog_11.rst b/doc/build/changelog/changelog_11.rst index 3a5b29decb..f4b782093f 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 a133f950d5..e721397b3e 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 5b6d3e7cf7..23bccafe92 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