diff --git a/rattail_corepos/corepos/importing/db/model.py b/rattail_corepos/corepos/importing/db/model.py index 54d0354..68a0584 100644 --- a/rattail_corepos/corepos/importing/db/model.py +++ b/rattail_corepos/corepos/importing/db/model.py @@ -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):