File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11368,4 +11368,28 @@ public function testSubstringFunction(): void {
1136811368 $ result = $ this ->assertQuery ( "SELECT SUBSTRING('abcdef' FROM 4) AS s " );
1136911369 $ this ->assertSame ( 'def ' , $ result [0 ]->s );
1137011370 }
11371+
11372+ /**
11373+ * Test CREATE TABLE with DEFAULT (now()) - GitHub issue #300
11374+ * Tests that DEFAULT with function calls in parentheses works correctly in AST driver.
11375+ *
11376+ * @see https://github.com/WordPress/sqlite-database-integration/issues/300
11377+ */
11378+ public function testCreateTableWithDefaultNowFunction (): void {
11379+ // Test the exact SQL from the issue
11380+ $ this ->assertQuery (
11381+ 'CREATE TABLE `test_now_default` (
11382+ `id` int NOT NULL,
11383+ `updated` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP
11384+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; '
11385+ );
11386+
11387+ // Insert a row to verify the default value works
11388+ $ this ->assertQuery ( 'INSERT INTO test_now_default (id) VALUES (1) ' );
11389+ $ result = $ this ->assertQuery ( 'SELECT * FROM test_now_default WHERE id = 1 ' );
11390+ $ this ->assertCount ( 1 , $ result );
11391+
11392+ // Verify the updated timestamp was set (should match YYYY-MM-DD HH:MM:SS format)
11393+ $ this ->assertRegExp ( '/\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/ ' , $ result [0 ]->updated );
11394+ }
1137111395}
You can’t perform that action at this time.
0 commit comments