[open-ils-commits] r12298 - trunk/Open-ILS/src/c-apps (scottmk)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Feb 25 12:58:19 EST 2009
Author: scottmk
Date: 2009-02-25 12:58:16 -0500 (Wed, 25 Feb 2009)
New Revision: 12298
Modified:
trunk/Open-ILS/src/c-apps/oils_cstore.c
Log:
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).
Modified: trunk/Open-ILS/src/c-apps/oils_cstore.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_cstore.c 2009-02-25 16:00:05 UTC (rev 12297)
+++ trunk/Open-ILS/src/c-apps/oils_cstore.c 2009-02-25 17:58:16 UTC (rev 12298)
@@ -2729,10 +2729,37 @@
// ... 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 @@
// 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;
More information about the open-ils-commits
mailing list