diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-05-17 21:51:40 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-05-17 21:51:40 +0000 |
| commit | 155466aad1c5ae4b43ed167a8b6e6013f0241370 (patch) | |
| tree | 7c237401dd7f0ee68097bb3d0474dd9c33b80500 /lib/sqlalchemy/orm/sync.py | |
| parent | 2be867ffac8881a4a20ca5387063ed207ac876dc (diff) | |
| download | sqlalchemy-155466aad1c5ae4b43ed167a8b6e6013f0241370.tar.gz | |
- Removed all* O(N) scanning behavior from the flush() process,
i.e. operations that were scanning the full session,
including an extremely expensive one that was erroneously
assuming primary key values were changing when this
was not the case.
* one edge case remains which may invoke a full scan,
if an existing primary key attribute is modified
to a new value.
Diffstat (limited to 'lib/sqlalchemy/orm/sync.py')
| -rw-r--r-- | lib/sqlalchemy/orm/sync.py | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/lib/sqlalchemy/orm/sync.py b/lib/sqlalchemy/orm/sync.py index dd979e1a8..c12f17aff 100644 --- a/lib/sqlalchemy/orm/sync.py +++ b/lib/sqlalchemy/orm/sync.py @@ -50,26 +50,18 @@ def populate_dict(source, source_mapper, dict_, synchronize_pairs): dict_[r.key] = value -def source_changes(uowcommit, source, source_mapper, synchronize_pairs): +def source_modified(uowcommit, source, source_mapper, synchronize_pairs): + """return true if the source object has changes from an old to a new value on the given + synchronize pairs + + """ for l, r in synchronize_pairs: try: prop = source_mapper._get_col_to_prop(l) except exc.UnmappedColumnError: _raise_col_to_prop(False, source_mapper, l, None, r) history = uowcommit.get_attribute_history(source, prop.key, passive=True) - if history.has_changes(): - return True - else: - return False - -def dest_changes(uowcommit, dest, dest_mapper, synchronize_pairs): - for l, r in synchronize_pairs: - try: - prop = dest_mapper._get_col_to_prop(r) - except exc.UnmappedColumnError: - _raise_col_to_prop(True, None, l, dest_mapper, r) - history = uowcommit.get_attribute_history(dest, prop.key, passive=True) - if history.has_changes(): + if len(history.deleted): return True else: return False |
