rearrangement for variable existance
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 12 Oct 2010 15:39:47 +0000 (15:39 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 12 Oct 2010 15:39:47 +0000 (15:39 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@18279 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/c-apps/oils_sql.c

index 0e8c445..48ad4f6 100644 (file)
@@ -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,