Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 71df3f3

Browse filesBrowse files
committed
fix usage in/not/is in path, still doesnt work "not is < 1"
1 parent cae7fe9 commit 71df3f3
Copy full SHA for 71df3f3

File tree

3 files changed

+181
-4
lines changed
Filter options

3 files changed

+181
-4
lines changed

‎expected/jsquery.out

Copy file name to clipboardExpand all lines: expected/jsquery.out
+145-3Lines changed: 145 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,148 @@ select 'a IN (0,null, "null", xxx, "zzz", 2)'::jsquery;
367367
"a" IN (0, null, "null", "xxx", "zzz", 2)
368368
(1 row)
369369

370+
select 'not < 1'::jsquery;
371+
jsquery
372+
-----------
373+
"not" < 1
374+
(1 row)
375+
376+
select 'not not < 1'::jsquery;
377+
jsquery
378+
-----------------
379+
NOT ("not" < 1)
380+
(1 row)
381+
382+
select 'not( not < 1)'::jsquery;
383+
jsquery
384+
-----------------
385+
NOT ("not" < 1)
386+
(1 row)
387+
388+
select 'not.x < 1'::jsquery;
389+
jsquery
390+
---------------
391+
"not"."x" < 1
392+
(1 row)
393+
394+
select 'x.not < 1'::jsquery;
395+
jsquery
396+
---------------
397+
"x"."not" < 1
398+
(1 row)
399+
400+
select 'is < 1'::jsquery;
401+
jsquery
402+
----------
403+
"is" < 1
404+
(1 row)
405+
406+
select 'in < 1'::jsquery;
407+
jsquery
408+
----------
409+
"in" < 1
410+
(1 row)
411+
412+
select 'not is < 1'::jsquery;
413+
ERROR: bad jsquery representation
414+
LINE 1: select 'not is < 1'::jsquery;
415+
^
416+
DETAIL: syntax error, unexpected '<' at or near "<"
417+
select 'not in < 1'::jsquery;
418+
ERROR: bad jsquery representation
419+
LINE 1: select 'not in < 1'::jsquery;
420+
^
421+
DETAIL: syntax error, unexpected '<', expecting '(' at or near "<"
422+
select 'in in (1,2)'::jsquery;
423+
jsquery
424+
----------------
425+
"in" IN (1, 2)
426+
(1 row)
427+
428+
select 'is in (1,2)'::jsquery;
429+
jsquery
430+
----------------
431+
"is" IN (1, 2)
432+
(1 row)
433+
434+
select 'not in (1,2)'::jsquery;
435+
jsquery
436+
-----------------
437+
"not" IN (1, 2)
438+
(1 row)
439+
440+
select 'in is numeric'::jsquery;
441+
jsquery
442+
-----------------
443+
"in" IS NUMERIC
444+
(1 row)
445+
446+
select 'is is numeric'::jsquery;
447+
jsquery
448+
-----------------
449+
"is" IS NUMERIC
450+
(1 row)
451+
452+
select 'not is numeric'::jsquery;
453+
jsquery
454+
------------------
455+
"not" IS NUMERIC
456+
(1 row)
457+
458+
select 'not.in < 1'::jsquery;
459+
jsquery
460+
----------------
461+
"not"."in" < 1
462+
(1 row)
463+
464+
select 'not.is < 1'::jsquery;
465+
jsquery
466+
----------------
467+
"not"."is" < 1
468+
(1 row)
469+
470+
select 'not.not < 1'::jsquery;
471+
jsquery
472+
-----------------
473+
"not"."not" < 1
474+
(1 row)
475+
476+
select 'in.in < 1'::jsquery;
477+
jsquery
478+
---------------
479+
"in"."in" < 1
480+
(1 row)
481+
482+
select 'in.is < 1'::jsquery;
483+
jsquery
484+
---------------
485+
"in"."is" < 1
486+
(1 row)
487+
488+
select 'in.not < 1'::jsquery;
489+
jsquery
490+
----------------
491+
"in"."not" < 1
492+
(1 row)
493+
494+
select 'is.in < 1'::jsquery;
495+
jsquery
496+
---------------
497+
"is"."in" < 1
498+
(1 row)
499+
500+
select 'is.is < 1'::jsquery;
501+
jsquery
502+
---------------
503+
"is"."is" < 1
504+
(1 row)
505+
506+
select 'is.not < 1'::jsquery;
507+
jsquery
508+
----------------
509+
"is"."not" < 1
510+
(1 row)
511+
370512
select '{"a": {"b": null}}'::jsonb @@ 'a.b = 1';
371513
?column?
372514
----------
@@ -989,9 +1131,9 @@ LINE 1: select 'a\r = x"\\abcd"'::jsquery AS err;
9891131
DETAIL: syntax error, unexpected STRING_P, expecting $end at or near """
9901132
--IS
9911133
select 'as IS boolean OR as is ARRAY OR as is ObJect OR as is Numeric OR as is string'::jsquery;
992-
jsquery
993-
------------------------------------------------------------------------------------------------
994-
(((("as" IS BOOLEAN OR "as" IS ARRAY) OR "as" IS OBJECT) OR "as" IS NUMBER) OR "as" IS STRING)
1134+
jsquery
1135+
-------------------------------------------------------------------------------------------------
1136+
(((("as" IS BOOLEAN OR "as" IS ARRAY) OR "as" IS OBJECT) OR "as" IS NUMERIC) OR "as" IS STRING)
9951137
(1 row)
9961138

9971139
select '{"as": "xxx"}' @@ 'as IS string'::jsquery;

‎jsquery_gram.y

Copy file name to clipboardExpand all lines: jsquery_gram.y
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ makeItemList(List *list) {
229229
%left OR_P
230230
%left AND_P
231231
%right NOT_P
232+
%nonassoc IN_P IS_P
233+
%left '(' ')'
234+
%nonassoc XXX
232235

233236
/* Grammar follows */
234237
%%
@@ -262,7 +265,7 @@ scalar_value:
262265

263266
opt_hint:
264267
HINT_P { $$ = $1; }
265-
| /* EMPTY */ { $$ = jsqIndexDefault; }
268+
| /* EMPTY */ %prec XXX { $$ = jsqIndexDefault; }
266269
;
267270

268271
value_list:
@@ -294,6 +297,7 @@ expr:
294297
| path '(' expr ')' { $$ = makeItemList(lappend($1, $3)); }
295298
| '(' expr ')' { $$ = $2; }
296299
| NOT_P expr { $$ = makeItemUnary(jqiNot, $2); }
300+
| NOT_P opt_hint right_expr { $3->hint = $2; $$ = makeItemList(lappend(lappend(NIL, makeItemKey(&$1)), $3)); }
297301
| expr AND_P expr { $$ = makeItemBinary(jqiAnd, $1, $3); }
298302
| expr OR_P expr { $$ = makeItemBinary(jqiOr, $1, $3); }
299303
;
@@ -334,6 +338,7 @@ path_elem_any:
334338
path:
335339
path_elem { $$ = lappend(NIL, $1); }
336340
| path '.' path_elem_any { $$ = lappend($1, $3); }
341+
| NOT_P '.' path_elem_any { $$ = lappend(lappend(NIL, makeItemKey(&$1)), $3); }
337342
;
338343

339344
%%

‎sql/jsquery.sql

Copy file name to clipboardExpand all lines: sql/jsquery.sql
+30Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,36 @@ select 'a < +10.1e+1'::jsquery;
7070
select 'a in (0,1,2)'::jsquery;
7171
select 'a IN (0,null, "null", xxx, "zzz", 2)'::jsquery;
7272

73+
select 'not < 1'::jsquery;
74+
select 'not not < 1'::jsquery;
75+
select 'not( not < 1)'::jsquery;
76+
select 'not.x < 1'::jsquery;
77+
select 'x.not < 1'::jsquery;
78+
79+
select 'is < 1'::jsquery;
80+
select 'in < 1'::jsquery;
81+
82+
select 'not is < 1'::jsquery;
83+
select 'not in < 1'::jsquery;
84+
85+
select 'in in (1,2)'::jsquery;
86+
select 'is in (1,2)'::jsquery;
87+
select 'not in (1,2)'::jsquery;
88+
89+
select 'in is numeric'::jsquery;
90+
select 'is is numeric'::jsquery;
91+
select 'not is numeric'::jsquery;
92+
93+
select 'not.in < 1'::jsquery;
94+
select 'not.is < 1'::jsquery;
95+
select 'not.not < 1'::jsquery;
96+
select 'in.in < 1'::jsquery;
97+
select 'in.is < 1'::jsquery;
98+
select 'in.not < 1'::jsquery;
99+
select 'is.in < 1'::jsquery;
100+
select 'is.is < 1'::jsquery;
101+
select 'is.not < 1'::jsquery;
102+
73103
select '{"a": {"b": null}}'::jsonb @@ 'a.b = 1';
74104
select '{"a": {"b": null}}'::jsonb @@ 'a.b = null';
75105
select '{"a": {"b": null}}'::jsonb @@ 'a.b = false';

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.