Skip to content
Myr

join/1: respect empty strings (fix #668)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Nicolas Williams · committed by Nicolas Williams · parent 8b5ff40 · Browse files · 2 files+5 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+5 added−1 removed

  • tests:+4 added−0 removed
  • other:+1 added−1 removed

2 files+5 added−1 removed

modified:tests/all.test+4 added
325 unmodified lines
326["a","b","c","d"]327"a,b,c,d"328"a/b/c/d"329330[.[]|join("a")]331[[""],["",""],["","",""]]332["","a","aa"]333334# Same check for flatten/1335flatten(-1,3,2,1)336[0, [1], [[2]], [[[3]]]]337[0,[1],[[2]],[[[3]]]]
822 unmodified lines
modified:builtin.c+1 added-1 removed
1063 unmodified lines
1064 "def values: select(. != null);",1065 "def scalars: select(. == null or . == true or . == false or type == \"number\" or type == \"string\");",1066 "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));",1067 "def leaf_paths: paths(scalars);",1068 "def join($x): reduce .[] as $i (\"\"; . + (if . == \"\" then $i else $x + $i end));",1068 "def join($x): reduce .[] as $i (null; (.//\"\") + (if . == null then $i else $x + $i end));",1069 "def flatten: reduce .[] as $i ([]; if $i | type == \"array\" then . + ($i | flatten) else . + [$i] end);",1070 "def flatten($x): reduce .[] as $i ([]; if $i | type == \"array\" and $x > 0 then . + ($i | flatten($x-1)) else . + [$i] end);",1071 "def range($x): range(0;$x);",1072 "def match(re; mode): _match_impl(re; mode; false)|.[];",
192 unmodified lines