Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
List information schema columns that store database name
  • Loading branch information
JanJakes committed Oct 15, 2025
commit 741915cc9d05a06c4c1a75e7eca7db5546c6288b
13 changes: 12 additions & 1 deletion wp-includes/sqlite-ast/class-wp-sqlite-driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3973,10 +3973,21 @@ public function translate_table_ref( WP_Parser_Node $node ): string {

// List all columns in the table, replacing columns targeting database
// name columns with the configured database name.
static $information_schema_db_column_map = array(
'SCHEMA_NAME' => true,
'TABLE_SCHEMA' => true,
'VIEW_SCHEMA' => true,
'INDEX_SCHEMA' => true,
'CONSTRAINT_SCHEMA' => true,
'UNIQUE_CONSTRAINT_SCHEMA' => true,
'REFERENCED_TABLE_SCHEMA' => true,
'TRIGGER_SCHEMA' => true,
);

$expanded_list = array();
foreach ( $columns as $column ) {
$quoted_column = $this->quote_sqlite_identifier( $column );
if ( str_contains( strtolower( $column ), 'schema' ) ) {
if ( isset( $information_schema_db_column_map[ strtoupper( $column ) ] ) ) {
$expanded_list[] = sprintf(
"IIF(%s = 'information_schema', %s, %s) AS %s",
$quoted_column,
Expand Down