Skip to content

Commit

Permalink
new safe updating mode
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Jan 22, 2015
1 parent 5ec8bc0 commit e8e4ac4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions data/src/entity_manager/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -3055,7 +3055,7 @@ def _save_query(self, entity):
# retrieves the proper modification time either from
# the entity or from the current system time, this allows
# the forced setting of an mtime (useful for bulk import)
_mtime = hasattr(entity, "_mtime") and entity._mtime or time.time()
_mtime = entity._mtime if hasattr(entity, "_mtime") else time.time()

# writes the comma to the query buffer only in case the
# is first flag is not set, then writes the modified time
Expand All @@ -3076,7 +3076,7 @@ def _save_query(self, entity):
# queries (multiple inserts)
return queries

def _update_query(self, entity, immutable = True):
def _update_query(self, entity, immutable = True, safe = True):
# retrieves the entity class associated with
# the entity
entity_class = entity.__class__
Expand Down Expand Up @@ -3145,8 +3145,11 @@ def _update_query(self, entity, immutable = True):
# update query (no need to update it), note that the
# unmapped relations are taken into account because if
# there are unmapped relations the modified time must be
# updated for the current entity class level
if not _entity_fields and not has_unmapped_relations:
# updated for the current entity class level, this is only
# applied in case the safe mode is not active, otherwise the
# update query is performed so that the modified time is
# changed to the most up-to-date value (performance penalty)
if not _entity_fields and not has_unmapped_relations and not safe:
# continues the loop, not going to create
# the query for update
continue
Expand Down Expand Up @@ -3211,7 +3214,7 @@ def _update_query(self, entity, immutable = True):
# retrieves the proper modification time either from
# the entity or from the current system time, this allows
# the forced setting of an mtime (useful for bulk import)
_mtime = hasattr(entity, "_mtime") and entity._mtime or time.time()
_mtime = entity._mtime if hasattr(entity, "_mtime") else time.time()

# writes the comma to the query buffer only in case the
# is first flag is not set, then writes the modified time
Expand Down

0 comments on commit e8e4ac4

Please sign in to comment.