Skip to content

Commit 22b16b4

Browse files
committed
Add support for SET NAMES and SET CHARACTER SET as a no-op
1 parent 0016a1a commit 22b16b4

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

tests/WP_SQLite_Driver_Tests.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6049,4 +6049,10 @@ public function testSelectColumnNames(): void {
60496049
$result = $this->assertQuery( "SELECT CONCAT('a', 'b') AS alias_concat" );
60506050
$this->assertSame( array( 'alias_concat' ), array_keys( (array) $result[0] ) );
60516051
}
6052+
6053+
public function testSetStatement(): void {
6054+
$this->assertQuery( 'SET NAMES utf8mb4' );
6055+
$this->assertQuery( 'SET CHARSET utf8mb4' );
6056+
$this->assertQuery( 'SET CHARACTER SET utf8mb4' );
6057+
}
60526058
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,6 +2089,20 @@ private function execute_set_statement( WP_Parser_Node $node ): void {
20892089
}
20902090

20912091
if (
2092+
$part instanceof WP_MySQL_Token
2093+
&& WP_MySQL_Lexer::NAMES_SYMBOL === $part->id
2094+
) {
2095+
// "SET NAMES ..." is a no-op for now.
2096+
// TODO: Validate charset compatibility with UTF-8.
2097+
// See: https://github.com/WordPress/sqlite-database-integration/issues/192
2098+
} elseif (
2099+
$part instanceof WP_Parser_Node
2100+
&& 'charsetClause' === $part->rule_name
2101+
) {
2102+
// "SET CHARACTER SET ..." is a no-op for now.
2103+
// TODO: Validate charset compatibility with UTF-8.
2104+
// See: https://github.com/WordPress/sqlite-database-integration/issues/192
2105+
} elseif (
20922106
$part instanceof WP_Parser_Node
20932107
&& (
20942108
'internalVariableName' === $part->rule_name

0 commit comments

Comments
 (0)