2
0
forked from Wavyzz/dolibarr

Fix psql search insensitive accent

This commit is contained in:
atm-ph
2019-02-07 17:47:17 +01:00
parent cdfeeafab9
commit ec7ef265b7

View File

@@ -152,6 +152,7 @@ class DoliDBPgsql extends DoliDB
*/
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 '';
@@ -311,7 +312,14 @@ class DoliDBPgsql extends DoliDB
}
// 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