Skip to content

Commit cca3e92

Browse files
committed
Merge pull request #669 from joelpurra/join-empty-array-668
Empty arrays join/1 to an empty string, fixes #668 bug introduced by 9760245
2 parents aeb52e2 + 4d05dc5 commit cca3e92

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

builtin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ static const char* const jq_builtins[] = {
10721072
"def scalars: select(. == null or . == true or . == false or type == \"number\" or type == \"string\");",
10731073
"def scalars_or_empty: select(. == null or . == true or . == false or type == \"number\" or type == \"string\" or ((type==\"array\" or type==\"object\") and length==0));",
10741074
"def leaf_paths: paths(scalars);",
1075-
"def join($x): reduce .[] as $i (null; (.//\"\") + (if . == null then $i else $x + $i end));",
1075+
"def join($x): reduce .[] as $i (null; (.//\"\") + (if . == null then $i else $x + $i end))//\"\";",
10761076
"def flatten: reduce .[] as $i ([]; if $i | type == \"array\" then . + ($i | flatten) else . + [$i] end);",
10771077
"def flatten($x): reduce .[] as $i ([]; if $i | type == \"array\" and $x > 0 then . + ($i | flatten($x-1)) else . + [$i] end);",
10781078
"def range($x): range(0;$x);",

tests/all.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,8 @@ join(",","/")
328328
"a/b/c/d"
329329

330330
[.[]|join("a")]
331-
[[""],["",""],["","",""]]
332-
["","a","aa"]
331+
[[],[""],["",""],["","",""]]
332+
["","","a","aa"]
333333

334334
# Same check for flatten/1
335335
flatten(-1,3,2,1)

0 commit comments

Comments
 (0)