[open-ils-commits] r12311 - trunk/Open-ILS/src/c-apps (scottmk)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Feb 26 15:06:52 EST 2009
Author: scottmk
Date: 2009-02-26 15:06:48 -0500 (Thu, 26 Feb 2009)
New Revision: 12311
Modified:
trunk/Open-ILS/src/c-apps/oils_cstore.c
Log:
In SELECT(): Don't allow virtual fields in the SELECT clause.
The old code allowed them, only to generate invalid queries
asking for non-existent columns.
Modified: trunk/Open-ILS/src/c-apps/oils_cstore.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_cstore.c 2009-02-26 18:44:41 UTC (rev 12310)
+++ trunk/Open-ILS/src/c-apps/oils_cstore.c 2009-02-26 20:06:48 UTC (rev 12311)
@@ -2764,6 +2764,34 @@
if( defaultselhash ) jsonObjectFree( defaultselhash );
free( core_class );
return NULL;
+ } else if ( str_is_true( osrfHashGet( field_def, "virtual" ) ) ) {
+ // Virtual field not allowed
+ osrfLogError(
+ OSRF_LOG_MARK,
+ "%s: Selected column \"%s\" for class \"%s\" is virtual",
+ MODULENAME,
+ col_name,
+ cname
+ );
+ if( ctx )
+ osrfAppSessionStatus(
+ ctx->session,
+ OSRF_STATUS_INTERNALSERVERERROR,
+ "osrfMethodException",
+ ctx->request,
+ "Selected column may not be virtual 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 );
+ if( defaultselhash ) jsonObjectFree( defaultselhash );
+ free( core_class );
+ return NULL;
}
if (locale) {
@@ -2819,6 +2847,34 @@
if( defaultselhash ) jsonObjectFree( defaultselhash );
free( core_class );
return NULL;
+ } else if ( str_is_true( osrfHashGet( field_def, "virtual" ) ) ) {
+ // No such field in current class
+ osrfLogError(
+ OSRF_LOG_MARK,
+ "%s: Selected column \"%s\" is virtual for class \"%s\"",
+ MODULENAME,
+ col_name,
+ cname
+ );
+ if( ctx )
+ osrfAppSessionStatus(
+ ctx->session,
+ OSRF_STATUS_INTERNALSERVERERROR,
+ "osrfMethodException",
+ ctx->request,
+ "Selected column is virtual 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 );
+ if( defaultselhash ) jsonObjectFree( defaultselhash );
+ free( core_class );
+ return NULL;
}
// Decide what to use as a column alias
More information about the open-ils-commits
mailing list