def rollback(self):
self._db_con.rollback()
+
+ def savepoint(self, name):
+ self.execute("SAVEPOINT %s" % name)
+ return True
+
+ def commit_savepoint(self, name):
+ self.execute("RELEASE SAVEPOINT %s" % name)
+ return True
+
+ def rollback_savepoint(self, name):
+ self.execute("ROLLBACK TO %s" % name)
+ return True
def _insert_document(self, doc_id, doc):
fields = self._get_fields()
- for f in doc:
- if not f in fields:
- self._create_field(f)
- table_f = '%s$%s' % (self.table_name, f)
- self._insert_field(doc_id, table_f, f, doc[f])
+ self.database.connection.savepoint("insert_document")
+ try:
+ for f in doc:
+ if not f in fields:
+ self._create_field(f)
+ table_f = '%s$%s' % (self.table_name, f)
+ self._insert_field(doc_id, table_f, f, doc[f])
+ self.database.connection.commit_savepoint("insert_document")
+ except:
+ self.database.connection.rollback_savepoint("insert_document")
+ raise
def _insert_field(self, doc_id, field_table, field_name, field_value):
values = {
def rollback(self):
pass
+
+ def savepoint(self, name):
+ pass
+
+ def commit_savepoint(self, name):
+ pass
+
+ def rollback_savepoint(self, name):
+ pass