Skip to content
This repository was archived by the owner on Jun 2, 2025. It is now read-only.

Commit ab1e94f

Browse files
committed
Add support for CURRENT_TIMESTAMP() and NOW()
1 parent 8432d2a commit ab1e94f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

tests/WP_SQLite_Driver_Tests.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3404,7 +3404,7 @@ public function testCurrentTimestamp() {
34043404
$this->assertRegExp( '/\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/', $results[0]->t );
34053405

34063406
// UPDATE
3407-
$this->assertQuery( 'UPDATE _dates SET option_value = NULL' );
3407+
$this->assertQuery( "UPDATE _dates SET option_value = ''" );
34083408
$results = $this->assertQuery( 'SELECT option_value AS t FROM _dates' );
34093409
$this->assertCount( 1, $results );
34103410
$this->assertEmpty( $results[0]->t );

wp-includes/sqlite-ast/class-wp-sqlite-driver.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,6 +1586,14 @@ private function translate_runtime_function_call( WP_Parser_Node $node ): string
15861586
}
15871587

15881588
switch ( $child->id ) {
1589+
case WP_MySQL_Lexer::CURRENT_TIMESTAMP_SYMBOL:
1590+
case WP_MySQL_Lexer::NOW_SYMBOL:
1591+
/*
1592+
* 1) SQLite doesn't support CURRENT_TIMESTAMP() with parentheses.
1593+
* 2) In MySQL, CURRENT_TIMESTAMP and CURRENT_TIMESTAMP() are an
1594+
* alias of NOW(). In SQLite, there is no NOW() function.
1595+
*/
1596+
return 'CURRENT_TIMESTAMP';
15891597
case WP_MySQL_Lexer::DATE_ADD_SYMBOL:
15901598
case WP_MySQL_Lexer::DATE_SUB_SYMBOL:
15911599
$nodes = $node->get_child_nodes();

0 commit comments

Comments
 (0)