fix for bug #2624: SQL error - CONCAT not supported by postgres

This commit is contained in:
Ralf Becker 2010-05-26 15:44:09 +00:00
parent 4b9b76bbe7
commit 579cf86bbc
2 changed files with 7 additions and 7 deletions

View File

@ -1042,7 +1042,7 @@ class so_sql
{ {
// This function can get called multiple times. Make sure it doesn't re-process. // This function can get called multiple times. Make sure it doesn't re-process.
if (empty($pattern) || is_array($pattern)) return $pattern; if (empty($pattern) || is_array($pattern)) return $pattern;
if(strpos($pattern, 'CONCAT') !== false) if(strpos($pattern, 'CAST(COALESCE(') !== false)
{ {
return $pattern; return $pattern;
} }
@ -1050,7 +1050,7 @@ class so_sql
$pattern = trim($pattern); $pattern = trim($pattern);
$criteria = array(); $criteria = array();
$filter = array(); $filter = array();
$columns = ''; $columns = array();
/* /*
* Special handling for numeric columns. They are only considered if the pattern is numeric. * Special handling for numeric columns. They are only considered if the pattern is numeric.
@ -1076,11 +1076,11 @@ class so_sql
$numeric_columns[] = $col; $numeric_columns[] = $col;
continue; continue;
} }
$columns .= "CAST(COALESCE($col,'') AS char),"; $columns[] = "CAST(COALESCE($col,'') AS char)";
} }
if(strlen($columns) > 0) if($columns)
{ {
$columns = 'CONCAT(' . substr($columns, 0, -1) . ')'; $columns = call_user_func_array(array($this->db,'concat'),$columns);
} }
// Break the search string into tokens // Break the search string into tokens

View File

@ -525,7 +525,7 @@ class so_sql_cf extends so_sql
// Multi-select - any entry with the filter value selected matches // Multi-select - any entry with the filter value selected matches
$sql_filter = str_replace($this->extra_value,'extra_filter.'. $sql_filter = str_replace($this->extra_value,'extra_filter.'.
$this->extra_value,$this->db->expression($this->extra_table,array( $this->extra_value,$this->db->expression($this->extra_table,array(
"CONCAT(',',{$this->extra_value},',') LIKE '%,$val,%'" $this->db->concat("','",$this->extra_value,"','").' '.$this->db->capabilities[egw_db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.$this->db->quote('%,'.$val.',%')
)) ))
); );
} }
@ -575,7 +575,7 @@ class so_sql_cf extends so_sql
{ {
// This function can get called multiple times. Make sure it doesn't re-process. // This function can get called multiple times. Make sure it doesn't re-process.
if (empty($pattern) || is_array($pattern)) return $pattern; if (empty($pattern) || is_array($pattern)) return $pattern;
if(strpos($pattern, 'CONCAT') !== false) if(strpos($pattern, 'CAST(COALESCE(') !== false)
{ {
return $pattern; return $pattern;
} }