Skip to content

Commit 38e8249

Browse files
committed
Fix SHOW DATABASES statement
1 parent 3cc9ea6 commit 38e8249

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2271,9 +2271,16 @@ private function execute_show_databases_statement( WP_Parser_Node $node ): void
22712271

22722272
$databases = $this->execute_sqlite_query(
22732273
sprintf(
2274-
'SELECT SCHEMA_NAME AS Database FROM %s%s ORDER BY SCHEMA_NAME',
2274+
'SELECT SCHEMA_NAME AS Database
2275+
FROM (
2276+
SELECT IIF(SCHEMA_NAME = ?, ?, SCHEMA_NAME) AS SCHEMA_NAME FROM %s ORDER BY SCHEMA_NAME
2277+
)%s',
22752278
$this->quote_sqlite_identifier( $schemata_table ),
22762279
isset( $condition ) ? ( ' WHERE TRUE ' . $condition ) : ''
2280+
),
2281+
array(
2282+
$this->get_saved_db_name(),
2283+
$this->main_db_name,
22772284
)
22782285
)->fetchAll( PDO::FETCH_OBJ );
22792286

0 commit comments

Comments
 (0)