jsquery icon indicating copy to clipboard operation
jsquery copied to clipboard

jsquery_in/out compatibility issue

Open pavanvd opened this issue 9 years ago • 1 comments

Hello,

While experimenting with jsquery, I encountered the following problem:

contrib_regression=# select 'NOT similar_product_ids.#: (NOT $ = "0440180295")'::jsquery::text::jsquery; ERROR: bad jsquery representation DETAIL: syntax error, unexpected NOT_P at or near " "

So, jsquery_in() fails to parse back the output generated by jsquery_out().

The problem seems to be with the jsquery_out(), which fails to add parenthesis around the expression: contrib_regression=# select 'NOT similar_product_ids.#: (NOT $ = "0440180295")'::jsquery::text;

text

NOT ("similar_product_ids".#:NOT ($ = "0440180295")) (1 row)

AFAICS jsquery_in() expects a parenthesis around the inner expression starting with 'NOT'. FWIW the attached patch fixes the problem for me, but I'm not sure if we should fix jsquery_out() or teach jsquery_in() to accept the above format.

Thanks, Pavan jsquery_in_out.txt

pavanvd avatar Mar 15 '16 10:03 pavanvd

I think inner parenthesis are not required for NOT. Committed fix to master branch. Please, check.

akorotkov avatar Mar 18 '16 16:03 akorotkov