Commit 2492b802 authored by alexpott's avatar alexpott
Browse files

Issue #2454733 followup by amateescu: Add a user-space case-insensitive...

Issue #2454733 followup by amateescu: Add a user-space case-insensitive collation to the SQLite driver
parent 98b74d2d
...@@ -553,8 +553,8 @@ public static function truncate($string, $max_length, $wordsafe = FALSE, $add_el ...@@ -553,8 +553,8 @@ public static function truncate($string, $max_length, $wordsafe = FALSE, $add_el
* Returns < 0 if $str1 is less than $str2; > 0 if $str1 is greater than * Returns < 0 if $str1 is less than $str2; > 0 if $str1 is greater than
* $str2, and 0 if they are equal. * $str2, and 0 if they are equal.
*/ */
public static function strCaseCmp($str1 , $str2) { public static function strcasecmp($str1 , $str2) {
return strcmp(mb_strtoupper($str1, 'utf-8'), mb_strtoupper($str2, 'utf-8')); return strcmp(static::strtoupper($str1), static::strtoupper($str2));
} }
/** /**
......
...@@ -125,7 +125,7 @@ public static function open(array &$connection_options = array()) { ...@@ -125,7 +125,7 @@ public static function open(array &$connection_options = array()) {
$pdo->sqliteCreateFunction('regexp', array(__CLASS__, 'sqlFunctionRegexp')); $pdo->sqliteCreateFunction('regexp', array(__CLASS__, 'sqlFunctionRegexp'));
// Create a user-space case-insensitive collation with UTF-8 support. // Create a user-space case-insensitive collation with UTF-8 support.
$pdo->sqliteCreateCollation('NOCASE_UTF8', array('Drupal\Component\Utility\Unicode', 'strCaseCmp')); $pdo->sqliteCreateCollation('NOCASE_UTF8', array('Drupal\Component\Utility\Unicode', 'strcasecmp'));
// Execute sqlite init_commands. // Execute sqlite init_commands.
if (isset($connection_options['init_commands'])) { if (isset($connection_options['init_commands'])) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment