[open-ils-commits] r12272 - trunk/Open-ILS/src/c-apps (scottmk)

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Feb 23 00:09:26 EST 2009


Author: scottmk
Date: 2009-02-23 00:09:23 -0500 (Mon, 23 Feb 2009)
New Revision: 12272

Modified:
   trunk/Open-ILS/src/c-apps/oils_cstore.c
Log:
In SELECT(): if selhash is not NULL and is not a JSON_HASH,
complain immediately instead of constructing a query that
is bound to fail.


Modified: trunk/Open-ILS/src/c-apps/oils_cstore.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_cstore.c	2009-02-23 00:53:52 UTC (rev 12271)
+++ trunk/Open-ILS/src/c-apps/oils_cstore.c	2009-02-23 05:09:23 UTC (rev 12272)
@@ -2466,6 +2466,46 @@
 	if (!selhash) {
 		selhash = defaultselhash = jsonNewObjectType(JSON_HASH);
 		jsonObjectSetKey( selhash, core_class, jsonNewObjectType(JSON_ARRAY) );
+	} else if( selhash->type != JSON_HASH ) {
+		const char* json_type;
+		switch ( selhash->type )
+		{
+			case 1 :
+				json_type = "JSON_ARRAY";
+				break;
+			case 2 :
+				json_type = "JSON_STRING";
+				break;
+			case 3 :
+				json_type = "JSON_NUMBER";
+				break;
+			case 4 :
+				json_type = "JSON_NULL";
+				break;
+			case 5 :
+				json_type = "JSON_BOOL";
+				break;
+			default :
+				json_type = "(unrecognized)";
+				break;
+		}
+		osrfLogError(
+			OSRF_LOG_MARK,
+			"%s: Expected JSON_HASH for SELECT clause; found %s",
+			MODULENAME,
+			json_type
+		);
+
+		if (ctx)
+			osrfAppSessionStatus(
+				ctx->session,
+				OSRF_STATUS_INTERNALSERVERERROR,
+				"osrfMethodException",
+				ctx->request,
+				"Malformed SELECT clause in JSON query"
+			);
+		free( core_class );
+		return NULL;
 	} else if ( (tmp_const = jsonObjectGetKeyConst( selhash, core_class )) && tmp_const->type == JSON_STRING ) {
 		char* _x = jsonObjectToSimpleString( tmp_const );
 		if (!strncmp( "*", _x, 1 )) {



More information about the open-ils-commits mailing list