From: scottmk Date: Wed, 25 Feb 2009 17:58:16 +0000 (+0000) Subject: Enhance error handling in SELECT(). When a selected column is X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d1f2f8ac115f4eeecff3d1e5ca03156e3d0d5755;p=evergreen%2Ftadl.git Enhance error handling in SELECT(). When a selected column is not defined in the IDL, issue a message and return without executing a query (instead of executing a query that is invalid because of an extra comma). git-svn-id: svn://svn.open-ils.org/ILS/trunk@12298 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 796498813a..6da51c06cf 100644 --- a/Open-ILS/src/c-apps/oils_cstore.c +++ b/Open-ILS/src/c-apps/oils_cstore.c @@ -2729,10 +2729,37 @@ char* SELECT ( // ... if it's a string, just toss it on the pile if (selfield->type == JSON_STRING) { - // again, just to be safe + // Look up the field in the IDL const char* col_name = selfield->value.s; osrfHash* field_def = osrfHashGet( class_field_set, col_name ); - if ( !field_def ) continue; // No such field in current class; skip it + if ( !field_def ) { + // No such field in current class + osrfLogError( + OSRF_LOG_MARK, + "%s: Selected column \"%s\" not defined in IDL for class \"%s\"", + MODULENAME, + col_name, + cname + ); + if( ctx ) + osrfAppSessionStatus( + ctx->session, + OSRF_STATUS_INTERNALSERVERERROR, + "osrfMethodException", + ctx->request, + "Selected column not defined in JSON query" + ); + jsonIteratorFree( select_itr ); + jsonIteratorFree( selclass_itr ); + jsonObjectFree( is_agg ); + buffer_free( sql_buf ); + buffer_free( select_buf ); + buffer_free( order_buf ); + buffer_free( group_buf ); + buffer_free( having_buf ); + free( core_class ); + return NULL; + } if (locale) { const char* i18n; @@ -2759,7 +2786,34 @@ char* SELECT ( // Get the field definition from the IDL osrfHash* field_def = osrfHashGet( class_field_set, col_name ); - if ( !field_def ) continue; // No such field defined in IDL. Skip it. + if ( !field_def ) { + // No such field in current class + osrfLogError( + OSRF_LOG_MARK, + "%s: Selected column \"%s\" is not defined in IDL for class \"%s\"", + MODULENAME, + col_name, + cname + ); + if( ctx ) + osrfAppSessionStatus( + ctx->session, + OSRF_STATUS_INTERNALSERVERERROR, + "osrfMethodException", + ctx->request, + "Selected column is not defined in JSON query" + ); + jsonIteratorFree( select_itr ); + jsonIteratorFree( selclass_itr ); + jsonObjectFree( is_agg ); + buffer_free( sql_buf ); + buffer_free( select_buf ); + buffer_free( order_buf ); + buffer_free( group_buf ); + buffer_free( having_buf ); + free( core_class ); + return NULL; + } // Decide what to use as a column alias char* _alias;