For the id_list methods: build the SELECT clause directly
authorscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 14 Jul 2009 17:12:01 +0000 (17:12 +0000)
committerscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 14 Jul 2009 17:12:01 +0000 (17:12 +0000)
instead of incurring the overhead of jsonParseStringFmt().

git-svn-id: svn://svn.open-ils.org/ILS/trunk@13588 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index a6af2c0..dff56e6 100644 (file)
@@ -824,15 +824,15 @@ int dispatchCRUDMethod ( osrfMethodContext* ctx ) {
 
                jsonObjectSetKey( rest_of_query, "no_i18n", jsonNewBoolObject( 1 ) );
 
-               jsonObjectSetKey(
-                       rest_of_query,
-            "select",
-            jsonParseStringFmt(
-                "{ \"%s\":[\"%s\"] }",
-                osrfHashGet( class_obj, "classname" ),
-                osrfHashGet( class_obj, "primarykey" )
-            )
-        );
+               // Build a SELECT list containing just the primary key,
+               // i.e. like { "classname":["keyname"] }
+               jsonObject* col_list_obj = jsonNewObjectType( JSON_ARRAY );
+               jsonObjectPush( col_list_obj,     // Load array with name of primary key
+                       jsonNewObject( osrfHashGet( class_obj, "primarykey" ) ) );
+               jsonObject* select_clause = jsonNewObjectType( JSON_HASH );
+               jsonObjectSetKey( select_clause, osrfHashGet( class_obj, "classname" ), col_list_obj );
+
+               jsonObjectSetKey( rest_of_query, "select", select_clause );
 
                obj = doFieldmapperSearch( ctx, class_obj, where_clause, rest_of_query, &err );