From 44c8391d327f589fb5e96bb7bbe0c08db1611441 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 13 Nov 2008 21:08:16 +0000 Subject: - Patch #321100 by hswong3i: empty insert statements are better handled now. Comes with tests. --- modules/simpletest/tests/database_test.test | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'modules/simpletest/tests/database_test.test') diff --git a/modules/simpletest/tests/database_test.test b/modules/simpletest/tests/database_test.test index e99a8c1b1..3325b189e 100644 --- a/modules/simpletest/tests/database_test.test +++ b/modules/simpletest/tests/database_test.test @@ -562,6 +562,24 @@ class DatabaseInsertDefaultsTestCase extends DatabaseTestCase { } } + /** + * Test that no action will be preformed if no fields are specified. + */ + function testDefaultEmptyInsert() { + try { + $num_records_before = (int) db_query("SELECT COUNT(*) FROM {test}")->fetchField(); + + $result = db_insert('test')->execute(); + $this->assertNull($result, t('Return NULL as no fields are specified.')); + + $num_records_after = (int) db_query("SELECT COUNT(*) FROM {test}")->fetchField(); + $this->assertIdentical($num_records_before, $num_records_after, t('Do nothing as no fields are specified.')); + } + catch (Exception $e) { + $this->assertTrue(FALSE, $e->getMessage()); + } + } + /** * Test that we can insert fields with values and defaults in the same query. */ -- cgit v1.2.3