Example #1
0
 def delete_by_id(self, table, row_id):
     # read only check
     self._check_write_ok()
     # gen sql
     sql, values = sqlgen.delete_by_id(table, row_id, self.paramstr)
     # execute sql
     cursor = self._execute(sql, values)
     rc = cursor.rowcount
     if rc == 1:
         return True
     if rc == 0:
         return False
     row_id = values[-1]
     assert False, (
             "delete_by_id(): more than 1 row deleted",
             (table.table_name, table.auto_id_col.col_name, row_id, rc)
         )
Example #2
0
 def test_bad_values(self):
     try:
         sqlgen.delete_by_id(Foo, "4", "?")
     except TypeError, e:
         self.assertEquals("AutoIdCol 'foo_id': int expected, got str", str(e))
Example #3
0
 def test_auto_id(self):
     try:
         sqlgen.delete_by_id(Foo, None, "?")
     except AssertionError, e:
         self.assertEquals("delete_by_id(): cannot use None for AutoIdCol", str(e))
Example #4
0
 def test_no_auto_id_col(self):
     try:
         sql = sqlgen.delete_by_id(Bar, 3, "?")
     except AssertionError, e:
         self.assertEquals("delete_by_id(): table 'bar' does not have AutoIdCol", str(e))
Example #5
0
 def test(self):
     sql, values = sqlgen.delete_by_id(Foo, 4, "%s")
     self.assertEquals("DELETE FROM foo WHERE foo_id=%s", sql)
     self.assertEquals([4], values)