From 7baa8325a91df76f167d103cd862285abf094baa Mon Sep 17 00:00:00 2001 From: miker Date: Sat, 3 Feb 2007 01:01:05 +0000 Subject: [PATCH] simplify 2-table joins git-svn-id: svn://svn.open-ils.org/ILS/trunk@6858 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/c-apps/oils_cstore.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/c-apps/oils_cstore.c b/Open-ILS/src/c-apps/oils_cstore.c index 8d02883054..071f87eb7a 100644 --- a/Open-ILS/src/c-apps/oils_cstore.c +++ b/Open-ILS/src/c-apps/oils_cstore.c @@ -1307,6 +1307,13 @@ join : { char* searchJOIN ( jsonObject* join_hash, osrfHash* leftmeta ) { + if (join_hash->type == JSON_STRING) { + char* __tmp = jsonObjectToSimpleString( join_hash ); + join_hash = jsonParseString("{}"); + jsonObjectSetKey(join_hash, __tmp, NULL); + free(__tmp); + } + growing_buffer* join_buf = buffer_init(128); char* leftclass = osrfHashGet(leftmeta, "classname"); @@ -1542,6 +1549,8 @@ char* SELECT ( jsonObjectNode* selfield = NULL; jsonObjectNode* snode = NULL; jsonObjectNode* onode = NULL; + jsonObject* found = NULL; + char* string = NULL; int first = 1; @@ -1631,7 +1640,14 @@ char* SELECT ( if (strcmp(core_class,cname)) { if (!join_hash) continue; - jsonObject* found = jsonObjectFindPath(join_hash, "//%s", cname); + if (join_hash->type == JSON_STRING) { + string = jsonObjectToSimpleString(join_hash); + found = strcmp(string,cname) ? NULL : jsonParseString("{\"1\":\"1\"}"); + free(string); + } else { + found = jsonObjectFindPath(join_hash, "//%s", cname); + } + if (!found->size) { jsonObjectFree(found); continue; -- 2.11.0