From: Adam Dickmeiss Date: Tue, 20 Dec 2011 11:56:08 +0000 (+0100) Subject: Fix CQL to CCL conversion for multiple terms X-Git-Tag: v4.2.24~5 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=871f1239cc0c8a2d4b2bd16a918a39c97633faa8 Fix CQL to CCL conversion for multiple terms Add two test cases as well. --- diff --git a/src/cql2ccl.c b/src/cql2ccl.c index 87881e4..58b5804 100644 --- a/src/cql2ccl.c +++ b/src/cql2ccl.c @@ -62,7 +62,7 @@ static void pr_term(const char **cpp, int stop_at_space, } pr("#", client_data); } - else if (*cp == ' ') + else if (*cp == ' ' && stop_at_space) break; else { @@ -130,17 +130,20 @@ static int node(struct cql_node *cn, { pr(ccl_field, client_data); pr(ccl_rel, client_data); + if (!split_op) + ccl_rel = 0; } pr_term(&cp, split_op ? 1 : 0, pr, client_data); - if (!split_op) - break; while (*cp == ' ') cp++; if (*cp == '\0') break; pr(" ", client_data); - pr(split_op, client_data); - pr(" ", client_data); + if (split_op) + { + pr(split_op, client_data); + pr(" ", client_data); + } } if (cn->u.st.extra_terms) { diff --git a/test/test_cql2ccl.c b/test/test_cql2ccl.c index e2f9b5f..482e47a 100644 --- a/test/test_cql2ccl.c +++ b/test/test_cql2ccl.c @@ -36,7 +36,7 @@ static int tst_query_s(const char *cql, const char *expected_ccl, if (!r) { ret = 0; - yaz_log(YLOG_WARN, "cql: diff %s", cql); + yaz_log(YLOG_WARN, "cql: diff: %s", cql); yaz_log(YLOG_WARN, " exp error"); yaz_log(YLOG_WARN, " got ccl %s", wrbuf_cstr(w)); } @@ -137,6 +137,10 @@ static void tst(void) YAZ_CHECK(tst_query("title any x", "title=\"x\"")); YAZ_CHECK(tst_query("title any x y", "title=\"x\" or title=\"y\"")); YAZ_CHECK(tst_query("title any \"x y\"", "title=\"x\" or title=\"y\"")); + + YAZ_CHECK(tst_query("title = \"x y\"", "title=\"x y\"")); + YAZ_CHECK(tst_query("title = x y", "title=\"x\" \"y\"")); + YAZ_CHECK(tst_query("dc.title=encyclopedia prox dinosaurs", "(dc.title=\"encyclopedia\") % (\"dinosaurs\")")); YAZ_CHECK(tst_query("dc.title=encyclopedia prox/distance<=3 dinosaurs",