Avoid touching DB records when dry-run importing
just in case storage engine doesn't support transactions!
This commit is contained in:
parent
a193a3458a
commit
40cb18f0cc
|
@ -43,8 +43,39 @@ class ToCore(importing.ToSQLAlchemy):
|
|||
"""
|
||||
Base class for all CORE "operational" model importers.
|
||||
"""
|
||||
# TODO: should we standardize on the 'id' primary key? (can we even?)
|
||||
# key = 'id'
|
||||
|
||||
def create_object(self, key, host_data):
|
||||
|
||||
# NOTE! some tables in CORE DB may be using the MyISAM storage engine,
|
||||
# which means it is *not* transaction-safe and therefore we cannot rely
|
||||
# on "rollback" if in dry-run mode! in other words we better not touch
|
||||
# the record at all, for dry run
|
||||
if self.dry_run:
|
||||
return host_data
|
||||
|
||||
return super(ToCore, self).create_object(key, host_data)
|
||||
|
||||
def update_object(self, obj, host_data, **kwargs):
|
||||
|
||||
# NOTE! some tables in CORE DB may be using the MyISAM storage engine,
|
||||
# which means it is *not* transaction-safe and therefore we cannot rely
|
||||
# on "rollback" if in dry-run mode! in other words we better not touch
|
||||
# the record at all, for dry run
|
||||
if self.dry_run:
|
||||
return obj
|
||||
|
||||
return super(ToCore, self).update_object(obj, host_data, **kwargs)
|
||||
|
||||
def delete_object(self, obj):
|
||||
|
||||
# NOTE! some tables in CORE DB may be using the MyISAM storage engine,
|
||||
# which means it is *not* transaction-safe and therefore we cannot rely
|
||||
# on "rollback" if in dry-run mode! in other words we better not touch
|
||||
# the record at all, for dry run
|
||||
if self.dry_run:
|
||||
return True
|
||||
|
||||
return super(ToCore, self).delete_object(obj)
|
||||
|
||||
|
||||
class ToCoreTrans(importing.ToSQLAlchemy):
|
||||
|
|
Loading…
Reference in a new issue