Skip to content
Merged
Prev Previous commit
Next Next commit
Improve method naming and docs
  • Loading branch information
JanJakes committed Oct 30, 2025
commit 8bc21a0bd5a5200c9b558c4fb23dfbd7632d4c67
9 changes: 5 additions & 4 deletions wp-includes/sqlite-ast/class-wp-sqlite-driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4570,7 +4570,7 @@ function ( $column ) use ( $is_strict_mode, $insert_map ) {
// When a column value is included, we need to apply type casting.
$position = array_search( $column['COLUMN_NAME'], $insert_list, true );
$identifier = $this->quote_sqlite_identifier( $select_list[ $position ] );
$fragment .= $this->cast_value_for_insert_or_update( $column['DATA_TYPE'], $identifier );
$fragment .= $this->cast_value_for_saving( $column['DATA_TYPE'], $identifier );
}
}

Expand Down Expand Up @@ -4704,7 +4704,7 @@ private function translate_update_list( string $table_name, WP_Parser_Node $node
}

// Apply type casting.
$value = $this->cast_value_for_insert_or_update( $data_type, $value );
$value = $this->cast_value_for_saving( $data_type, $value );

// In MySQL non-STRICT mode, when a column is declared as NOT NULL,
// updating to a NULL value saves an IMPLICIT DEFAULT value instead.
Expand Down Expand Up @@ -5009,13 +5009,14 @@ private function create_table_reference_map( WP_Parser_Node $node ): array {
}

/**
* Emulate MySQL type casting for INSERT or UPDATE values.
* Emulate MySQL type casting for values to be saved to the database
* using INSERT, REPLACE, or UPDATE statements.
*
* @param string $mysql_data_type The MySQL data type.
* @param string $translated_value The original translated value.
* @return string The translated value.
*/
private function cast_value_for_insert_or_update(
private function cast_value_for_saving(
string $mysql_data_type,
string $translated_value
): string {
Expand Down