[open-ils-commits] r12886 - trunk/Open-ILS/src/c-apps (scottmk)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Apr 16 08:48:55 EDT 2009
Author: scottmk
Date: 2009-04-16 08:48:54 -0400 (Thu, 16 Apr 2009)
New Revision: 12886
Modified:
trunk/Open-ILS/src/c-apps/oils_cstore.c
Log:
In oils_cstore.c: fix autojoin, i.e. the facility for constructing
a join when the JSON query doesn't specify the columns involved.
When looking up a foreign key linkage in the IDL, ignore the parent
table's end of the link (where reltype = "has_many"), because the
parent doesn't know the name of the column at the other end.
Now an autojoin can work regardless of which table is subordinate
to which.
Modified: trunk/Open-ILS/src/c-apps/oils_cstore.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_cstore.c 2009-04-15 19:43:01 UTC (rev 12885)
+++ trunk/Open-ILS/src/c-apps/oils_cstore.c 2009-04-16 12:48:54 UTC (rev 12886)
@@ -2247,7 +2247,6 @@
jsonIteratorFree(search_itr);
return NULL;
}
- field = field;
} else if (!field && !fkey) {
osrfHash* _links = oilsIDL_links( leftclass );
@@ -2260,10 +2259,15 @@
const char* other_class = osrfHashGet( curr_link, "class" );
if( other_class && !strcmp( other_class, class ) ) {
- // Found a link between the classes
- fkey = osrfHashIteratorKey( itr );
- field = osrfHashGet( curr_link, "key" );
- break;
+ // In the IDL, the parent class doesn't know then names of the child
+ // columns that are pointing to it, so don't use that end of the link
+ const char* reltype = osrfHashGet( curr_link, "reltype" );
+ if( reltype && strcmp( reltype, "has_many" ) ) {
+ // Found a link between the classes
+ fkey = osrfHashIteratorKey( itr );
+ field = osrfHashGet( curr_link, "key" );
+ break;
+ }
}
}
osrfHashIteratorFree( itr );
@@ -2280,10 +2284,15 @@
const char* other_class = osrfHashGet( curr_link, "class" );
if( other_class && !strcmp( other_class, leftclass ) ) {
- // Found a link between the classes
- fkey = osrfHashIteratorKey( itr );
- field = osrfHashGet( curr_link, "key" );
- break;
+ // In the IDL, the parent class doesn't know then names of the child
+ // columns that are pointing to it, so don't use that end of the link
+ const char* reltype = osrfHashGet( curr_link, "reltype" );
+ if( reltype && strcmp( reltype, "has_many" ) ) {
+ // Found a link between the classes
+ field = osrfHashIteratorKey( itr );
+ fkey = osrfHashGet( curr_link, "key" );
+ break;
+ }
}
}
osrfHashIteratorFree( itr );
More information about the open-ils-commits
mailing list