Skip to content

Commit 3a91db4

Browse files
committed
Correct behavior of $append function
1 parent 93345fd commit 3a91db4

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/jsonata/functions.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -2010,15 +2010,9 @@ def append(arg1: Optional[Any], arg2: Optional[Any]) -> Optional[Any]:
20102010
arg1 = utils.Utils.create_sequence(arg1)
20112011
if not (isinstance(arg2, list)):
20122012
arg2 = utils.Utils.JList([arg2])
2013-
# else
2014-
# // Arg2 was a list: add it as a list element (don't flatten)
2015-
# ((List)arg1).add((List)arg2)
20162013

20172014
arg1 = utils.Utils.JList(arg1) # create a new copy!
2018-
if isinstance(arg2, utils.Utils.JList) and arg2.cons:
2019-
arg1.append(arg2)
2020-
else:
2021-
arg1.extend(arg2)
2015+
arg1.extend(arg2)
20222016
return arg1
20232017

20242018
@staticmethod

tests/array_test.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import jsonata
2+
3+
4+
class TestArray:
5+
6+
def test_array(self):
7+
assert jsonata.Jsonata("$.[{ }] ~> $reduce($append)").evaluate([True, True]) == [{}, {}]

0 commit comments

Comments
 (0)