Skip to content

Commit ab00d0a

Browse files
committed
Use case-insensitive comparison for INSERT column names
1 parent 5a61725 commit ab00d0a

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4435,7 +4435,7 @@ private function translate_insert_or_replace_body_in_non_strict_mode(
44354435
$columns_table = $this->information_schema_builder->get_table_name( $is_temporary, 'columns' );
44364436
$columns = $this->execute_sqlite_query(
44374437
'
4438-
SELECT column_name, is_nullable, column_default, data_type, extra
4438+
SELECT LOWER(column_name) AS COLUMN_NAME, is_nullable, column_default, data_type, extra
44394439
FROM ' . $this->quote_sqlite_identifier( $columns_table ) . '
44404440
WHERE table_schema = ?
44414441
AND table_name = ?
@@ -4450,18 +4450,20 @@ private function translate_insert_or_replace_body_in_non_strict_mode(
44504450
if ( $fields_node ) {
44514451
// This is the optional "INSERT INTO ... (field1, field2, ...)" list.
44524452
foreach ( $fields_node->get_child_nodes() as $field ) {
4453-
$insert_list[] = $this->unquote_sqlite_identifier( $this->translate( $field ) );
4453+
$column_name = $this->unquote_sqlite_identifier( $this->translate( $field ) );
4454+
$insert_list[] = strtolower( $column_name );
44544455
}
44554456
} elseif ( 'updateList' === $node->rule_name ) {
44564457
// This is the "INSERT INTO ... SET c1 = v1, c2 = v2, ... " syntax.
44574458
foreach ( $node->get_child_nodes( 'updateElement' ) as $update_element ) {
44584459
$column_ref = $update_element->get_first_child_node( 'columnRef' );
4459-
$insert_list[] = $this->unquote_sqlite_identifier( $this->translate( $column_ref ) );
4460+
$column_name = $this->unquote_sqlite_identifier( $this->translate( $column_ref ) );
4461+
$insert_list[] = strtolower( $column_name );
44604462
}
44614463
} else {
44624464
// When no explicit field list is provided, all columns are required.
44634465
foreach ( array_column( $columns, 'COLUMN_NAME' ) as $column_name ) {
4464-
$insert_list[] = $column_name;
4466+
$insert_list[] = strtolower( $column_name );
44654467
}
44664468
}
44674469

0 commit comments

Comments
 (0)