From: miker Date: Tue, 12 Oct 2010 15:39:47 +0000 (+0000) Subject: rearrangement for variable existance X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=298fde1a1c12c6e963d3cd720f3f26b862132c89;p=evergreen%2Fbjwebb.git rearrangement for variable existance git-svn-id: svn://svn.open-ils.org/ILS/trunk@18279 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/c-apps/oils_sql.c b/Open-ILS/src/c-apps/oils_sql.c index 0e8c445b1..48ad4f619 100644 --- a/Open-ILS/src/c-apps/oils_sql.c +++ b/Open-ILS/src/c-apps/oils_sql.c @@ -4788,24 +4788,11 @@ static char* buildOrderByFromArray( osrfMethodContext* ctx, const jsonObject* or return NULL; } - const ClassInfo* order_class_info = search_alias( class_alias ); - if( ! order_class_info ) { - osrfLogWarn( OSRF_LOG_MARK, "%s: ORDER BY clause references class \"%s\" " - "not in FROM clause, skipping it", modulename, class_alias ); - continue; - } - const char* class_alias = jsonObjectGetString( jsonObjectGetKeyConst( order_spec, "class" )); const char* field = jsonObjectGetString( jsonObjectGetKeyConst( order_spec, "field" )); - // Add a separating comma, except at the beginning - if( first ) - first = 0; - else - OSRF_BUFFER_ADD( order_buf, ", " ); - if( !field || !class_alias ) { osrfLogError( OSRF_LOG_MARK, "%s: Missing class or field name in field specification of ORDER BY clause", @@ -4822,6 +4809,19 @@ static char* buildOrderByFromArray( osrfMethodContext* ctx, const jsonObject* or return NULL; } + const ClassInfo* order_class_info = search_alias( class_alias ); + if( ! order_class_info ) { + osrfLogWarn( OSRF_LOG_MARK, "%s: ORDER BY clause references class \"%s\" " + "not in FROM clause, skipping it", modulename, class_alias ); + continue; + } + + // Add a separating comma, except at the beginning + if( first ) + first = 0; + else + OSRF_BUFFER_ADD( order_buf, ", " ); + osrfHash* field_def = osrfHashGet( order_class_info->fields, field ); if( !field_def ) { osrfLogError( OSRF_LOG_MARK,