add NOT EXISTS counterpart to EXISTS
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 14 Nov 2008 03:55:50 +0000 (03:55 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 14 Nov 2008 03:55:50 +0000 (03:55 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@11178 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index a10563f..ae10adb 100644 (file)
@@ -1657,19 +1657,34 @@ static char* searchWHERE ( const jsonObject* search_hash, osrfHash* meta, int op
                 free(subpred);
             } else if ( !strcasecmp("-exists",search_itr->key) ) {
                 char* subpred = SELECT(
-                       ctx,
-                       jsonObjectGetKey( node, "select" ),
-                       jsonObjectGetKey( node, "from" ),
-                       jsonObjectGetKey( node, "where" ),
-                       jsonObjectGetKey( node, "having" ),
-                       jsonObjectGetKey( node, "order_by" ),
-                       jsonObjectGetKey( node, "limit" ),
-                       jsonObjectGetKey( node, "offset" ),
-                       SUBSELECT
+                    ctx,
+                    jsonObjectGetKey( node, "select" ),
+                    jsonObjectGetKey( node, "from" ),
+                    jsonObjectGetKey( node, "where" ),
+                    jsonObjectGetKey( node, "having" ),
+                    jsonObjectGetKey( node, "order_by" ),
+                    jsonObjectGetKey( node, "limit" ),
+                    jsonObjectGetKey( node, "offset" ),
+                    SUBSELECT
                 );
 
                 buffer_fadd(sql_buf, "EXISTS ( %s )", subpred);
                 free(subpred);
+            } else if ( !strcasecmp("-not-exists",search_itr->key) ) {
+                char* subpred = SELECT(
+                    ctx,
+                    jsonObjectGetKey( node, "select" ),
+                    jsonObjectGetKey( node, "from" ),
+                    jsonObjectGetKey( node, "where" ),
+                    jsonObjectGetKey( node, "having" ),
+                    jsonObjectGetKey( node, "order_by" ),
+                    jsonObjectGetKey( node, "limit" ),
+                    jsonObjectGetKey( node, "offset" ),
+                    SUBSELECT
+                );
+
+                buffer_fadd(sql_buf, "NOT EXISTS ( %s )", subpred);
+                free(subpred);
             } else {
 
                 char* class = osrfHashGet(meta, "classname");