diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 8e57b29109e..392e0998d6b 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -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