When returning a list of bind variables: If a default_ or actual_value
authorscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 14 Jul 2010 18:55:05 +0000 (18:55 +0000)
committerscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 14 Jul 2010 18:55:05 +0000 (18:55 +0000)
is undefined for a given variable, leave it out of the JSON object
altogether, rather than create an entry with a JSON null for it.

That way the client can distinguish between an undefined value and
a value defined as null.

M    Open-ILS/src/c-apps/buildSQL.c

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

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

index 07f018f..a2e008d 100644 (file)
@@ -96,11 +96,15 @@ jsonObject* oilsBindVarList( osrfHash* bindvar_list ) {
                        attr = jsonNewObject( bind->description );
                        jsonObjectSetKey( bind_obj, "description", attr );
 
-                       attr = jsonObjectClone( bind->default_value );
-                       jsonObjectSetKey( bind_obj, "default_value", attr );
+                       if( bind->default_value ) {
+                               attr = jsonObjectClone( bind->default_value );
+                               jsonObjectSetKey( bind_obj, "default_value", attr );
+                       }
 
-                       attr = jsonObjectClone( bind->actual_value );
-                       jsonObjectSetKey( bind_obj, "actual_value", attr );
+                       if( bind->actual_value ) {
+                               attr = jsonObjectClone( bind->actual_value );
+                               jsonObjectSetKey( bind_obj, "actual_value", attr );
+                       }
 
                        // Add the bind variable to the list
                        jsonObjectSetKey( list, osrfHashIteratorKey( iter ), bind_obj );