def test_zero_id(self): if isinstance(test_db, MySQLDatabase): # Need to explicitly tell MySQL it's OK to use zero. test_db.execute_sql("SET SESSION sql_mode='NO_AUTO_VALUE_ON_ZERO'") query = 'insert into users (id, username) values (%s, %s)' % ( test_db.interpolation, test_db.interpolation) test_db.execute_sql(query, (0, 'foo')) Blog.insert(title='foo2', user=0).execute() u = User.get(User.id == 0) b = Blog.get(Blog.user == u) self.assertTrue(u == u) self.assertTrue(u == b.user)
def set_foreign_key_pragma(self, is_enabled): if not isinstance(test_db, SqliteDatabase): return state = 'on' if is_enabled else 'off' test_db.execute_sql('PRAGMA foreign_keys = %s' % state)
def tearDown(self): super(TestPostgresqlSchema, self).tearDown() test_db.execute_sql('DROP SCHEMA huey;')
def setUp(self): test_db.execute_sql('CREATE SCHEMA huey;') super(TestPostgresqlSchema, self).setUp()
def execute_queries(n): for i in range(n): test_db.execute_sql('select 1;')
def tearDown(self): super(TestPostgresqlSchema,self).tearDown() test_db.execute_sql('DROP SCHEMA huey;')
def setUp(self): test_db.execute_sql('CREATE SCHEMA huey;') super(TestPostgresqlSchema,self).setUp()