Add a regression test for negative indices and fix a pick/1 test
This commit is contained in:
1 parent
f85c9fcb78
commit
0733fd3d58
3 files changed
+11
-10
No files matched your search
@@ -1048,10 +1048,11 @@ sections:
|
|||||||
- title: "`pick(pathexps)`"
|
- title: "`pick(pathexps)`"
|
||||||
body: |
|
body: |
|
||||||
|
|
||||||
Emit the projection of the input object or array defined by the specified
|
Emit the projection of the input object or array defined by the
|
||||||
sequence of path expressions, such that if p is any one of these specifications,
|
specified sequence of path expressions, such that if `p` is any
|
||||||
then `(. | p)` will evaluate to the same value as `(. | pick(pathexps) | p)`.
|
one of these specifications, then `(. | p)` will evaluate to the
|
||||||
For arrays, negative indices and .[m:n] specifications should not be used.
|
same value as `(. | pick(pathexps) | p)`. For arrays, negative
|
||||||
|
indices and `.[m:n]` specifications should not be used.
|
||||||
|
|
||||||
examples:
|
examples:
|
||||||
- program: 'pick(.a, .b.c, .x)'
|
- program: 'pick(.a, .b.c, .x)'
|
||||||
|
|||||||
Generated
+1
-1
@@ -1050,7 +1050,7 @@ jq \'map_values(\. // empty)\'
|
|||||||
.IP "" 0
|
.IP "" 0
|
||||||
.
|
.
|
||||||
.SS "pick(pathexps)"
|
.SS "pick(pathexps)"
|
||||||
Emit the projection of the input object or array defined by the specified sequence of path expressions, such that if p is any one of these specifications, then \fB(\. | p)\fR will evaluate to the same value as \fB(\. | pick(pathexps) | p)\fR\. For arrays, negative indices and \.[m:n] specifications should not be used\.
|
Emit the projection of the input object or array defined by the specified sequence of path expressions, such that if \fBp\fR is any one of these specifications, then \fB(\. | p)\fR will evaluate to the same value as \fB(\. | pick(pathexps) | p)\fR\. For arrays, negative indices and \fB\.[m:n]\fR specifications should not be used\.
|
||||||
.
|
.
|
||||||
.IP "" 4
|
.IP "" 4
|
||||||
.
|
.
|
||||||
|
|||||||
+5
-5
@@ -248,9 +248,9 @@ null
|
|||||||
2
|
2
|
||||||
3
|
3
|
||||||
|
|
||||||
.[-2]
|
[.[-4,-3,-2,-1,0,1,2,3]]
|
||||||
[1,2,3]
|
[1,2,3]
|
||||||
2
|
[null,1,2,3,1,2,3,null]
|
||||||
|
|
||||||
[range(0;10)]
|
[range(0;10)]
|
||||||
null
|
null
|
||||||
@@ -1052,9 +1052,9 @@ pick(first|first)
|
|||||||
[[10]]
|
[[10]]
|
||||||
|
|
||||||
# negative indices in path expressions (since last/1 is .[-1])
|
# negative indices in path expressions (since last/1 is .[-1])
|
||||||
pick(last)
|
try pick(last) catch .
|
||||||
[[10,20],30]
|
[1,2]
|
||||||
[null,30]
|
"Out of bounds negative array index"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Assignment
|
# Assignment
|
||||||
|
|||||||
Reference in new issue
Block a user