File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11293,4 +11293,28 @@ public function testSubstringFunction(): void {
1129311293 $ result = $ this ->assertQuery ( "SELECT SUBSTRING('abcdef' FROM 4) AS s " );
1129411294 $ this ->assertSame ( 'def ' , $ result [0 ]->s );
1129511295 }
11296+
11297+ /**
11298+ * Test CREATE TABLE with DEFAULT (now()) - GitHub issue #300
11299+ * Tests that DEFAULT with function calls in parentheses works correctly in AST driver.
11300+ *
11301+ * @see https://github.com/WordPress/sqlite-database-integration/issues/300
11302+ */
11303+ public function testCreateTableWithDefaultNowFunction (): void {
11304+ // Test the exact SQL from the issue
11305+ $ this ->assertQuery (
11306+ 'CREATE TABLE `test_now_default` (
11307+ `id` int NOT NULL,
11308+ `updated` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP
11309+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; '
11310+ );
11311+
11312+ // Insert a row to verify the default value works
11313+ $ this ->assertQuery ( 'INSERT INTO test_now_default (id) VALUES (1) ' );
11314+ $ result = $ this ->assertQuery ( 'SELECT * FROM test_now_default WHERE id = 1 ' );
11315+ $ this ->assertCount ( 1 , $ result );
11316+
11317+ // Verify the updated timestamp was set (should match YYYY-MM-DD HH:MM:SS format)
11318+ $ this ->assertRegExp ( '/\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/ ' , $ result [0 ]->updated );
11319+ }
1129611320}
You can’t perform that action at this time.
0 commit comments