File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -86,8 +86,9 @@ def _extract_items(
8686 index += 1
8787 if is_dict (obj ):
8888 try :
89- # We are at the last entry in the path so we must remove the field
90- if (len (path )) == index :
89+ # Remove the field if there are no more dict keys in the path,
90+ # only "<array>" traversal markers or end.
91+ if all (p == "<array>" for p in path [index :]):
9192 item = obj .pop (key )
9293 else :
9394 item = obj [key ]
Original file line number Diff line number Diff line change @@ -35,6 +35,15 @@ def test_multiple_files() -> None:
3535 assert query == {"documents" : [{}, {}]}
3636
3737
38+ def test_top_level_file_array () -> None :
39+ query = {"files" : [b"file one" , b"file two" ], "title" : "hello" }
40+ assert extract_files (query , paths = [["files" , "<array>" ]]) == [
41+ ("files[]" , b"file one" ),
42+ ("files[]" , b"file two" ),
43+ ]
44+ assert query == {"title" : "hello" }
45+
46+
3847@pytest .mark .parametrize (
3948 "query,paths,expected" ,
4049 [
You can’t perform that action at this time.
0 commit comments