Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit4f82c4a

Browse files
committed
fix wrong output of filter in jsquery, improve tests
1 parente76f92d commit4f82c4a

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

‎expected/jsquery.out

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,21 +1454,21 @@ select '?( not b>0). x'::jsquery;
14541454
(1 row)
14551455

14561456
select 'a.?(b>0 and x= 0 ) .c'::jsquery;
1457-
jsquery
1458-
-----------------------------------
1459-
"a" ?(("b" > 0 AND "x" = 0)) ."c"
1457+
jsquery
1458+
------------------------------------
1459+
"a". ?(("b" > 0 AND "x" = 0)) ."c"
14601460
(1 row)
14611461

14621462
select 'a.$. ?(b>0 and x= 0 ) . c.k'::jsquery;
1463-
jsquery
1464-
-----------------------------------------
1465-
"a".$ ?(("b" > 0 AND "x" = 0)) ."c"."k"
1463+
jsquery
1464+
------------------------------------------
1465+
"a".$. ?(("b" > 0 AND "x" = 0)) ."c"."k"
14661466
(1 row)
14671467

14681468
select 'a.$.? (b>0 and x.*= 0 ).c.k'::jsquery;
1469-
jsquery
1470-
-------------------------------------------
1471-
"a".$ ?(("b" > 0 AND "x".* = 0)) ."c"."k"
1469+
jsquery
1470+
--------------------------------------------
1471+
"a".$. ?(("b" > 0 AND "x".* = 0)) ."c"."k"
14721472
(1 row)
14731473

14741474
select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a < 0) (b=20)';
@@ -1615,6 +1615,18 @@ select '{"a": {"b": {"c": 1}}}'::jsonb ~~ '?(*.c >0)';
16151615
[{"a": {"b": {"c": 1}}}]
16161616
(1 row)
16171617

1618+
select '{"tags":[{"term":["NYC", "CYN"]}, {"term":["1NYC", "1CYN"]} ]}'::jsonb ~~ 'tags.#.term.#. ? ( $ = "NYC")';
1619+
?column?
1620+
----------
1621+
["NYC"]
1622+
(1 row)
1623+
1624+
select '{"tags":[{"term":["NYC", "CYN"]}, {"term":["1NYC", "1CYN"]} ]}'::jsonb ~~ 'tags.#.term. ? ( # = "NYC")';
1625+
?column?
1626+
------------------
1627+
[["NYC", "CYN"]]
1628+
(1 row)
1629+
16181630
--ALL
16191631
select 'a.*: = 4'::jsquery;
16201632
jsquery

‎jsquery_io.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ printJsQueryItem(StringInfo buf, JsQueryItem *v, bool inKey, bool printBracketes
378378
appendStringInfo(buf,"#%u",v->arrayIndex);
379379
break;
380380
casejqiFilter:
381+
if (inKey)
382+
appendStringInfoChar(buf,'.');
381383
appendBinaryStringInfo(buf," ?(",3);
382384
jsqGetArg(v,&elem);
383385
printJsQueryItem(buf,&elem, false, false);

‎sql/jsquery.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,8 @@ select '[1,2,3]'::jsonb ~~ ' ?(#:.$ > 2).$';
325325
select'[1,2,3]'::jsonb ~~' ?(#:.$ > 0).$';
326326
select'{"a": {"b": {"c": 1}}}'::jsonb ~~'*.?(c >0)';
327327
select'{"a": {"b": {"c": 1}}}'::jsonb ~~'?(*.c >0)';
328+
select'{"tags":[{"term":["NYC", "CYN"]}, {"term":["1NYC", "1CYN"]} ]}'::jsonb ~~'tags.#.term.#. ? ( $ = "NYC")';
329+
select'{"tags":[{"term":["NYC", "CYN"]}, {"term":["1NYC", "1CYN"]} ]}'::jsonb ~~'tags.#.term. ? ( # = "NYC")';
328330

329331
--ALL
330332
select'a.*: = 4'::jsquery;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp