diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-02-02 22:56:19 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-02-02 22:56:19 +0000 |
| commit | c1e0978556c50a44b371a196fecfb08f0117c047 (patch) | |
| tree | 38757ccc1fc2affffbbf980adaed2b682e6899e0 /lib/sqlalchemy/orm/sync.py | |
| parent | 9a84fa585bf7ee9db7de0abc9b175cd397199335 (diff) | |
| download | sqlalchemy-c1e0978556c50a44b371a196fecfb08f0117c047.tar.gz | |
- Primary key values can now be changed on a joined-table inheritance
object, and ON UPDATE CASCADE will be taken into account when
the flush happens. Set the new "passive_updates" flag to False
on mapper() when using SQLite or MySQL/MyISAM. [ticket:1362]
- flush() now detects when a primary key column was updated by
an ON UPDATE CASCADE operation from another primary key, and
can then locate the row for a subsequent UPDATE on the new PK
value. This occurs when a relation() is there to establish
the relationship as well as passive_updates=True. [ticket:1671]
Diffstat (limited to 'lib/sqlalchemy/orm/sync.py')
| -rw-r--r-- | lib/sqlalchemy/orm/sync.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/sync.py b/lib/sqlalchemy/orm/sync.py index 8826ab3aa..8a30a9e62 100644 --- a/lib/sqlalchemy/orm/sync.py +++ b/lib/sqlalchemy/orm/sync.py @@ -10,7 +10,8 @@ based on join conditions. from sqlalchemy.orm import exc, util as mapperutil -def populate(source, source_mapper, dest, dest_mapper, synchronize_pairs): +def populate(source, source_mapper, dest, dest_mapper, + synchronize_pairs, uowcommit, passive_updates): for l, r in synchronize_pairs: try: value = source_mapper._get_state_attr_by_column(source, l) @@ -21,6 +22,15 @@ def populate(source, source_mapper, dest, dest_mapper, synchronize_pairs): dest_mapper._set_state_attr_by_column(dest, r, value) except exc.UnmappedColumnError: _raise_col_to_prop(True, source_mapper, l, dest_mapper, r) + + # techically the "r.primary_key" check isn't + # needed here, but we check for this condition to limit + # how often this logic is invoked for memory/performance + # reasons, since we only need this info for a primary key + # destination. + if l.primary_key and r.primary_key and \ + r.references(l) and passive_updates: + uowcommit.attributes[("pk_cascaded", dest, r)] = True def clear(dest, dest_mapper, synchronize_pairs): for l, r in synchronize_pairs: |
