@@ -34,7 +34,10 @@ public function __construct(IDBConnection $db) {
3434 public function report ($ user , $ from , $ to , $ filterProjectId , $ filterClientId , $ filterTagId , $ timegroup , $ groupOn1 , $ groupOn2 , $ admin , $ start , $ limit ){
3535
3636 $ selectFields = ['min(wi.id) as id ' , 'sum(duration) as "totalDuration" ' ];
37+
38+ $ pg = 0 ;
3739 if ($ this ->dbengine != 'MYSQL ' ) {
40+ $ pg = 1 ;
3841 if (empty ($ timegroup )){
3942 $ selectFields []= "to_timestamp(min(start))::date as time " ;
4043 } elseif ($ timegroup == 'week ' ) {
@@ -173,14 +176,22 @@ public function report($user, $from, $to, $filterProjectId, $filterClientId, $fi
173176 if ($ groupOn1 == 'name ' ){
174177 $ groups [] = 'wi.name ' ;
175178 } else {
176- $ groups [] = '" ' .$ groupOn1 .'" ' ;
179+ if ($ pg ) { // postgres needs quotes on names
180+ $ groups [] = '" ' .$ groupOn1 .'" ' ;
181+ } else {
182+ $ groups [] = $ groupOn1 ;
183+ }
177184 }
178185 if (!empty ($ groupOn2 )){
179186 if ($ groupOn2 == "project " || $ groupOn2 == "client " || $ groupOn2 == "name " || $ groupOn2 == "userUid " ){
180187 if ($ groupOn2 == 'name ' ){
181188 $ groups [] = 'wi.name ' ;
182189 } else {
183- $ groups [] = '" ' .$ groupOn2 .'" ' ;
190+ if ($ pg ) {
191+ $ groups [] = '" ' .$ groupOn2 .'" ' ;// postgres needs quotes on names
192+ } else {
193+ $ groups [] = $ groupOn2 ;
194+ }
184195 }
185196 }
186197 }
@@ -195,8 +206,8 @@ public function report($user, $from, $to, $filterProjectId, $filterClientId, $fi
195206 $ limit = 10000 ;
196207 }
197208 $ sql = 'SELECT ' .$ selectItems .' where ' .implode (" and " ,$ filters ).' ' .$ group . ' order by time desc ' ;
198- //var_dump($sql);
199- //var_dump($params);
209+ // var_dump($sql);
210+ // var_dump($params);
200211 return $ this ->findEntities ($ sql , $ params , $ limit , $ start );
201212 }
202213
0 commit comments