* Timesheet/PostgreSQL: fix SQL error when selecting a timerange

This commit is contained in:
Ralf Becker 2013-08-29 10:59:00 +00:00
parent f5e00e4bad
commit a4ec8796af
2 changed files with 7 additions and 3 deletions

View File

@ -1156,6 +1156,8 @@ class so_sql
}
$alias = $col;
if (stripos($col, ' AS ')) list($col, $alias) = preg_split('/ +AS +/i', $col);
// do NOT group by constant expressions
if (preg_match('/^ *(-?[0-9]+|".*"|\'.*\'|NULL) *$/i', $col)) continue;
if (!in_array($col, $group_by_cols) && !in_array($alias, $group_by_cols))
{
$group_by_cols[] = $alias;

View File

@ -559,9 +559,11 @@ class timesheet_bo extends so_sql_cf
$union_order[] = 'is_sum_'.$type;
$sum_extra_cols[$type]{0} = '1';
// the $type sum
parent::search($criteria,$sum_ts_id[$type].",'','','',MIN(ts_start),SUM(ts_duration) AS ts_duration,".
($this->quantity_sum ? "SUM(ts_quantity) AS ts_quantity" : '0').",0,NULL,0,0,0,0,0,SUM($total_sql) AS ts_total",
'GROUP BY '.$sum_sql[$type],$sum_extra_cols,$wildcard,$empty,$op,'UNION',$filter,$join,$need_full_no_count);
parent::search($criteria,array(
$sum_ts_id[$type],"''","''","''",'MIN(ts_start)','SUM(ts_duration) AS ts_duration',
($this->quantity_sum ? "SUM(ts_quantity) AS ts_quantity" : '0'),
'0','NULL','0','0','0','0','0',"SUM($total_sql) AS ts_total"
),'GROUP BY '.$sum_sql[$type],$sum_extra_cols,$wildcard,$empty,$op,'UNION',$filter,$join,$need_full_no_count);
$sum_extra_cols[$type]{0} = '0';
}
$union_order[] = 'ts_start '.$sort;