@@ -34,7 +34,10 @@ public function __construct(IDBConnection $db) {
34
34
public function report ($ user , $ from , $ to , $ filterProjectId , $ filterClientId , $ filterTagId , $ timegroup , $ groupOn1 , $ groupOn2 , $ admin , $ start , $ limit ){
35
35
36
36
$ selectFields = ['min(wi.id) as id ' , 'sum(duration) as "totalDuration" ' ];
37
+
38
+ $ pg = 0 ;
37
39
if ($ this ->dbengine != 'MYSQL ' ) {
40
+ $ pg = 1 ;
38
41
if (empty ($ timegroup )){
39
42
$ selectFields []= "to_timestamp(min(start))::date as time " ;
40
43
} elseif ($ timegroup == 'week ' ) {
@@ -173,14 +176,22 @@ public function report($user, $from, $to, $filterProjectId, $filterClientId, $fi
173
176
if ($ groupOn1 == 'name ' ){
174
177
$ groups [] = 'wi.name ' ;
175
178
} else {
176
- $ groups [] = '" ' .$ groupOn1 .'" ' ;
179
+ if ($ pg ) { // postgres needs quotes on names
180
+ $ groups [] = '" ' .$ groupOn1 .'" ' ;
181
+ } else {
182
+ $ groups [] = $ groupOn1 ;
183
+ }
177
184
}
178
185
if (!empty ($ groupOn2 )){
179
186
if ($ groupOn2 == "project " || $ groupOn2 == "client " || $ groupOn2 == "name " || $ groupOn2 == "userUid " ){
180
187
if ($ groupOn2 == 'name ' ){
181
188
$ groups [] = 'wi.name ' ;
182
189
} else {
183
- $ groups [] = '" ' .$ groupOn2 .'" ' ;
190
+ if ($ pg ) {
191
+ $ groups [] = '" ' .$ groupOn2 .'" ' ;// postgres needs quotes on names
192
+ } else {
193
+ $ groups [] = $ groupOn2 ;
194
+ }
184
195
}
185
196
}
186
197
}
@@ -195,8 +206,8 @@ public function report($user, $from, $to, $filterProjectId, $filterClientId, $fi
195
206
$ limit = 10000 ;
196
207
}
197
208
$ 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);
200
211
return $ this ->findEntities ($ sql , $ params , $ limit , $ start );
201
212
}
202
213
0 commit comments