--- /dev/null
+.. change::
+ :tags: bug, orm
+ :tickets: 4215
+ :versions: 1.3.0b1
+
+ Fixed bug where using :meth:`.Mutable.associate_with` or
+ :meth:`.Mutable.as_mutable` in conjunction with a class that has non-
+ primary mappers set up with alternatively-named attributes would produce an
+ attribute error. Since non-primary mappers are not used for persistence,
+ the mutable extension now excludes non-primary mappers from its
+ instrumentation steps.
+
"""
def listen_for_type(mapper, class_):
+ if mapper.non_primary:
+ return
for prop in mapper.column_attrs:
if isinstance(prop.columns[0].type, sqltype):
cls.associate_with_attribute(getattr(class_, prop.key))
schema_event_check = False
def listen_for_type(mapper, class_):
+ if mapper.non_primary:
+ return
for prop in mapper.column_attrs:
if (
schema_event_check and
self._test_non_mutable()
+class MutableIncludeNonPrimaryTest(MutableWithScalarJSONTest):
+ @classmethod
+ def setup_mappers(cls):
+ foo = cls.tables.foo
+
+ mapper(Foo, foo)
+ mapper(Foo, foo, non_primary=True, properties={
+ "foo_bar": foo.c.data
+ })
+
+
class MutableColumnCopyJSONTest(_MutableDictTestBase, fixtures.MappedTest):
@classmethod
)
+class MutableAssocIncludeNonPrimaryTest(MutableAssociationScalarPickleTest):
+ @classmethod
+ def setup_mappers(cls):
+ foo = cls.tables.foo
+
+ mapper(Foo, foo)
+ mapper(Foo, foo, non_primary=True, properties={
+ "foo_bar": foo.c.data
+ })
+
+
class MutableAssociationScalarJSONTest(_MutableDictTestBase,
fixtures.MappedTest):