add support for DISTINCT on aggregate function, like COUNT( DISTINCT x )
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 26 Mar 2010 19:07:58 +0000 (19:07 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 26 Mar 2010 19:07:58 +0000 (19:07 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@16010 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/c-apps/oils_cstore.c

index d7e130f..63c1358 100644 (file)
@@ -2564,8 +2564,14 @@ static char* searchFieldTransform (const char* class_alias, osrfHash* field, con
                        return NULL;
                }
 
-               buffer_fadd( sql_buf, "%s(\"%s\".%s",
-                       field_transform, class_alias, osrfHashGet(field, "name"));
+        if( obj_is_true( jsonObjectGetKeyConst( node, "distinct" ) ) ) {
+                   buffer_fadd( sql_buf, "%s(DISTINCT \"%s\".%s",
+                field_transform, class_alias, osrfHashGet(field, "name"));
+        } else {
+                   buffer_fadd( sql_buf, "%s(\"%s\".%s",
+                field_transform, class_alias, osrfHashGet(field, "name"));
+        }
+
                const jsonObject* array = jsonObjectGetKeyConst( node, "params" );
 
                if (array) {