summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/unitofwork.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-09-27 05:08:22 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-09-27 05:08:22 +0000
commitdf9c1a10b568cb89aec41fcb0c7c31a1ae75943c (patch)
treec5a45acd6719070254fc8483db9981408c334cbd /lib/sqlalchemy/orm/unitofwork.py
parentb4112538dbd46ee7d3c25fc35f3c43aed342e429 (diff)
downloadsqlalchemy-df9c1a10b568cb89aec41fcb0c7c31a1ae75943c.tar.gz
- added an automatic "row switch" feature to mapping, which will
detect a pending instance/deleted instance pair with the same identity key and convert the INSERT/DELETE to a single UPDATE - "association" mappings simplified to take advantage of automatic "row switch" feature - fixes [ticket:311]
Diffstat (limited to 'lib/sqlalchemy/orm/unitofwork.py')
-rw-r--r--lib/sqlalchemy/orm/unitofwork.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/sqlalchemy/orm/unitofwork.py b/lib/sqlalchemy/orm/unitofwork.py
index 076b80882..008236877 100644
--- a/lib/sqlalchemy/orm/unitofwork.py
+++ b/lib/sqlalchemy/orm/unitofwork.py
@@ -54,7 +54,7 @@ class UOWEventHandler(attributes.AttributeExtension):
sess.save_or_update(newvalue, entity_name=ename)
class UOWProperty(attributes.InstrumentedAttribute):
- """overrides InstrumentedAttribute to provide an extra AttributeExtension to all managed attributes
+ """override InstrumentedAttribute to provide an extra AttributeExtension to all managed attributes
as well as the 'property' property."""
def __init__(self, manager, class_, key, uselist, callable_, typecallable, cascade=None, extension=None, **kwargs):
extension = util.to_list(extension or [])
@@ -65,12 +65,14 @@ class UOWProperty(attributes.InstrumentedAttribute):
property = property(lambda s:class_mapper(s.class_).props[s.key], doc="returns the MapperProperty object associated with this property")
class UOWAttributeManager(attributes.AttributeManager):
- """overrides AttributeManager to provide the UOWProperty instance for all InstrumentedAttributes."""
+ """override AttributeManager to provide the UOWProperty instance for all InstrumentedAttributes."""
def create_prop(self, class_, key, uselist, callable_, typecallable, **kwargs):
return UOWProperty(self, class_, key, uselist, callable_, typecallable, **kwargs)
class UnitOfWork(object):
- """main UOW object which stores lists of dirty/new/deleted objects. provides top-level "flush" functionality as well as the transaction boundaries with the SQLEngine(s) involved in a write operation."""
+ """main UOW object which stores lists of dirty/new/deleted objects.
+ provides top-level "flush" functionality as well as the transaction
+ boundaries with the SQLEngine(s) involved in a write operation."""
def __init__(self, identity_map=None):
if identity_map is not None:
self.identity_map = identity_map
@@ -159,6 +161,7 @@ class UnitOfWork(object):
# store objects whose fate has been decided
processed = util.Set()
+
# put all saves/updates into the flush context. detect orphans and throw them into deleted.
for obj in self.new.union(dirty).intersection(objset).difference(self.deleted):
if obj in processed: