Skip to content

Commit

Permalink
Merge pull request #10527 from atm-ph/fix_8.0_psql_search_insensitive…
Browse files Browse the repository at this point in the history
…_accent

Fix psql search insensitive accent
  • Loading branch information
eldy committed Feb 8, 2019
2 parents bd3f0da + 51515a4 commit e5d7a86
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion htdocs/core/db/pgsql.class.php
Expand Up @@ -152,6 +152,7 @@ function __construct($type, $host, $user, $pass, $name='', $port=0)
*/
static function convertSQLFromMysql($line,$type='auto',$unescapeslashquot=false)
{
global $conf;
// Removed empty line if this is a comment line for SVN tagging
if (preg_match('/^--\s\$Id/i',$line)) {
return '';
Expand Down Expand Up @@ -311,7 +312,14 @@ static function convertSQLFromMysql($line,$type='auto',$unescapeslashquot=false)
}

// To have postgresql case sensitive
$line=str_replace(' LIKE \'',' ILIKE \'',$line);
$count_like=0;
$line=str_replace(' LIKE \'',' ILIKE \'',$line,$count_like);
if (!empty($conf->global->PSQL_USE_UNACCENT) && $count_like > 0)
{
// @see https://docs.postgresql.fr/11/unaccent.html : 'unaccent()' function must be installed before
$line=preg_replace('/\s+(\(+\s*)([a-zA-Z0-9\-\_\.]+) ILIKE /', ' \1unaccent(\2) ILIKE ', $line);
}

$line=str_replace(' LIKE BINARY \'',' LIKE \'',$line);

// Replace INSERT IGNORE into INSERT
Expand Down

0 comments on commit e5d7a86

Please sign in to comment.