Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/WP_SQLite_Driver_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -3705,6 +3705,19 @@ public function testCurrentTimestamp() {
$this->assertQuery( 'DELETE FROM _dates WHERE option_value = CURRENT_TIMESTAMP()' );
}

public function testDatabaseFunction(): void {
$this->assertQuery( "SELECT DATABASE(), CONCAT('test-', (SELECT DATABASE()))" );
$this->assertEquals(
array(
(object) array(
'DATABASE()' => 'wp',
"CONCAT('test-', (SELECT DATABASE()))" => 'test-wp',
),
),
$this->engine->get_query_results()
);
}

public function testGroupByHaving() {
$this->assertQuery(
'CREATE TABLE _tmp_table (
Expand Down
2 changes: 2 additions & 0 deletions wp-includes/sqlite-ast/class-wp-sqlite-driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3354,6 +3354,8 @@ private function translate_runtime_function_call( WP_Parser_Node $node ): string
}

switch ( $child->id ) {
case WP_MySQL_Lexer::DATABASE_SYMBOL:
return $this->connection->quote( $this->db_name );
case WP_MySQL_Lexer::CURRENT_TIMESTAMP_SYMBOL:
case WP_MySQL_Lexer::NOW_SYMBOL:
/*
Expand Down
Loading