[open-ils-commits] r13785 - trunk/Open-ILS/src/c-apps (scottmk)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Jul 30 22:26:36 EDT 2009
Author: scottmk
Date: 2009-07-30 22:26:33 -0400 (Thu, 30 Jul 2009)
New Revision: 13785
Modified:
trunk/Open-ILS/src/c-apps/oils_cstore.c
Log:
Tightened validation a bit in oils_cstore.c:
1. Issue a warning if the SELECT list is empty for a given table alias
(other than the core class). This happens when we try to do the
equivalent of SELECT * for a non-core class.
2. Return an error if the generated SELECT list is empty. This can happen
in a case like the following:
{
"select":{ "aout":null },
"from":{ "aou":"aout" }
}
...because there is nothing from the core class, and we don't build default
SELECT lists for non-core classes.
Modified: trunk/Open-ILS/src/c-apps/oils_cstore.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_cstore.c 2009-07-31 01:20:34 UTC (rev 13784)
+++ trunk/Open-ILS/src/c-apps/oils_cstore.c 2009-07-31 02:26:33 UTC (rev 13785)
@@ -2397,7 +2397,6 @@
if (!field || !fkey) {
// Do another such search, with the classes reversed
- //_links = oilsIDL_links( class );
// For each link defined for the joined class:
// see if the link references the left class
@@ -3050,11 +3049,20 @@
osrfHash* class_field_set = class_info->fields;
const char* class_pkey = osrfHashGet( idlClass, "primarykey" );
const char* class_tname = osrfHashGet( idlClass, "tablename" );
-
- // stitch together the column list ...
- jsonIterator* select_itr = jsonNewIterator( selclass );
- while ( (selfield = jsonIteratorNext( select_itr )) ) { // for each SELECT column
+ if( 0 == selclass->size ) {
+ osrfLogWarning(
+ OSRF_LOG_MARK,
+ "%s: No columns selected from \"%s\"",
+ MODULENAME,
+ cname
+ );
+ }
+
+ // stitch together the column list for the current table alias...
+ jsonIterator* select_itr = jsonNewIterator( selclass );
+ while ( (selfield = jsonIteratorNext( select_itr )) ) { // for each SELECT column
+
// If we need a separator comma, add one
if (first) {
first = 0;
@@ -3312,21 +3320,42 @@
}
#endif
- sel_pos++;
- } // end while -- iterating across SELECT columns
+ sel_pos++;
+ } // end while -- iterating across SELECT columns
- jsonIteratorFree(select_itr);
- } // end while -- iterating across classes
+ jsonIteratorFree(select_itr);
+ } // end while -- iterating across classes
- jsonIteratorFree(selclass_itr);
- }
+ jsonIteratorFree(selclass_itr);
+ }
char* col_list = buffer_release(select_buf);
+
+ // Make sure the SELECT list isn't empty. This can happen if we try to
+ // build a default SELECT clause from a non-core table.
+
+ if( ! *col_list ) {
+ if (ctx)
+ osrfAppSessionStatus(
+ ctx->session,
+ OSRF_STATUS_INTERNALSERVERERROR,
+ "osrfMethodException",
+ ctx->request,
+ "SELECT list is empty"
+ );
+ free( col_list );
+ buffer_free( group_buf );
+ if( defaultselhash ) jsonObjectFree( defaultselhash );
+ free( join_clause );
+ return NULL;
+ }
+
char* table = NULL;
if (from_function) table = searchValueTransform(join_hash);
else table = strdup( curr_query->core.source_def );
+
if( !table ) {
if (ctx)
osrfAppSessionStatus(
More information about the open-ils-commits
mailing list