skip unknown order_by entries instead of erroring
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 12 Oct 2010 15:19:54 +0000 (15:19 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 12 Oct 2010 15:19:54 +0000 (15:19 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@18278 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index 7fb0fb6..0e8c445 100644 (file)
@@ -4416,26 +4416,10 @@ char* SELECT (
 
                                ClassInfo* order_class_info = search_alias( class_itr->key );
                                if( ! order_class_info ) {
-                                       osrfLogError( OSRF_LOG_MARK,
-                                               "%s: Invalid class \"%s\" referenced in ORDER BY clause",
+                                       osrfLogWarn( OSRF_LOG_MARK,
+                                               "%s: Invalid class \"%s\" referenced in ORDER BY clause, skipping it",
                                                modulename, class_itr->key );
-                                       if( ctx )
-                                               osrfAppSessionStatus(
-                                                       ctx->session,
-                                                       OSRF_STATUS_INTERNALSERVERERROR,
-                                                       "osrfMethodException",
-                                                       ctx->request,
-                                                       "Invalid class referenced in ORDER BY clause -- "
-                                                       "see error log for more details"
-                                               );
-                                       jsonIteratorFree( class_itr );
-                                       buffer_free( order_buf );
-                                       free( having_buf );
-                                       buffer_free( group_buf );
-                                       buffer_free( sql_buf );
-                                       if( defaultselhash )
-                                               jsonObjectFree( defaultselhash );
-                                       return NULL;
+                                       continue;
                                }
 
                                osrfHash* field_list_def = order_class_info->fields;
@@ -4804,6 +4788,13 @@ 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 =
@@ -4831,22 +4822,6 @@ static char* buildOrderByFromArray( osrfMethodContext* ctx, const jsonObject* or
                        return NULL;
                }
 
-               const ClassInfo* order_class_info = search_alias( class_alias );
-               if( ! order_class_info ) {
-                       osrfLogError( OSRF_LOG_MARK, "%s: ORDER BY clause references class \"%s\" "
-                               "not in FROM clause", modulename, class_alias );
-                       if( ctx )
-                               osrfAppSessionStatus(
-                                       ctx->session,
-                                       OSRF_STATUS_INTERNALSERVERERROR,
-                                       "osrfMethodException",
-                                       ctx->request,
-                                       "Invalid class referenced in ORDER BY clause -- see error log for more details"
-                               );
-                       free( order_buf );
-                       return NULL;
-               }
-
                osrfHash* field_def = osrfHashGet( order_class_info->fields, field );
                if( !field_def ) {
                        osrfLogError( OSRF_LOG_MARK,