From: scottmk Date: Mon, 23 Feb 2009 05:09:23 +0000 (+0000) Subject: In SELECT(): if selhash is not NULL and is not a JSON_HASH, X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b55038011cf61ed04f04b724cee0dc1657e5b650;p=Evergreen.git 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. git-svn-id: svn://svn.open-ils.org/ILS/trunk@12272 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/c-apps/oils_cstore.c b/Open-ILS/src/c-apps/oils_cstore.c index c501b833d6..5ee1056bcd 100644 --- a/Open-ILS/src/c-apps/oils_cstore.c +++ b/Open-ILS/src/c-apps/oils_cstore.c @@ -2466,6 +2466,46 @@ char* SELECT ( 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 )) {