diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2018-03-12 12:50:52 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2018-03-12 12:50:52 -0400 |
| commit | 0fd508ad32a6f94653757a5ae10c1eae14e099fc (patch) | |
| tree | 457bcc42d36a999692df758fef6aed8e426d54be /lib/sqlalchemy/ext | |
| parent | f3e18baa00489b2a85293edcdb4c98cb409c8c93 (diff) | |
| download | sqlalchemy-0fd508ad32a6f94653757a5ae10c1eae14e099fc.tar.gz | |
Ignore non-primary mappers within mutable instrumentation
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.
Change-Id: I2630d9f771a171aece03181ccf9159885f68f25e
Fixes: #4215
Diffstat (limited to 'lib/sqlalchemy/ext')
| -rw-r--r-- | lib/sqlalchemy/ext/mutable.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/sqlalchemy/ext/mutable.py b/lib/sqlalchemy/ext/mutable.py index 955aa3ae1..014cef3cc 100644 --- a/lib/sqlalchemy/ext/mutable.py +++ b/lib/sqlalchemy/ext/mutable.py @@ -566,6 +566,8 @@ class Mutable(MutableBase): """ 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)) @@ -619,6 +621,8 @@ class Mutable(MutableBase): 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 |
