@@ -210,18 +210,28 @@ public Object command(final OCommandRequestText iCommand) {
210
210
final ODocument doc = new ODocument ();
211
211
list .add (doc );
212
212
213
- // MERGE NON AGGREGATED FIELDS
214
- for (Map .Entry <String , Object > entry : ((Map <String , Object >) result ).entrySet ()) {
215
- final List <Object > resultSet = (List <Object >) entry .getValue ();
213
+ boolean hasNonAggregates = false ;
214
+ for (Map .Entry <String , Object > p : proj .entrySet ()) {
215
+ if (!(p .getValue () instanceof OSQLFunctionRuntime )) {
216
+ hasNonAggregates = true ;
217
+ break ;
218
+ }
219
+ }
220
+
221
+ if (hasNonAggregates ) {
222
+ // MERGE NON AGGREGATED FIELDS
223
+ for (Map .Entry <String , Object > entry : ((Map <String , Object >) result ).entrySet ()) {
224
+ final List <Object > resultSet = (List <Object >) entry .getValue ();
216
225
217
- for (Object r : resultSet ) {
218
- if (r instanceof ODocument ) {
219
- final ODocument d = (ODocument ) r ;
226
+ for (Object r : resultSet ) {
227
+ if (r instanceof ODocument ) {
228
+ final ODocument d = (ODocument ) r ;
220
229
221
- for (Map .Entry <String , Object > p : proj .entrySet ()) {
222
- // WRITE THE FIELD AS IS
223
- if (!(p .getValue () instanceof OSQLFunctionRuntime ))
224
- doc .field (p .getKey (), p .getValue ());
230
+ for (Map .Entry <String , Object > p : proj .entrySet ()) {
231
+ // WRITE THE FIELD AS IS
232
+ if (!(p .getValue () instanceof OSQLFunctionRuntime ))
233
+ doc .field (p .getKey (), p .getValue ());
234
+ }
225
235
}
226
236
}
227
237
}
0 commit comments