mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-17 16:38:54 +00:00
* Fix #1784 * test/cases/dsl-mapsum-mapdiff-mapexcept/0033/
This commit is contained in:
parent
5f14dbc752
commit
56add7d1f0
6 changed files with 34 additions and 1 deletions
|
|
@ -222,6 +222,8 @@ func BIF_mapselect(mlrvals []*mlrval.Mlrval) *mlrval.Mlrval {
|
|||
for _, element := range selectArg.AcquireArrayValue() {
|
||||
if element.IsString() {
|
||||
newKeys[element.AcquireStringValue()] = true
|
||||
} else if element.IsInt() {
|
||||
newKeys[element.String()] = true
|
||||
} else {
|
||||
return mlrval.FromNotStringError("mapselect", element)
|
||||
}
|
||||
|
|
@ -260,8 +262,10 @@ func BIF_mapexcept(mlrvals []*mlrval.Mlrval) *mlrval.Mlrval {
|
|||
for _, element := range exceptArg.AcquireArrayValue() {
|
||||
if element.IsString() {
|
||||
newMap.Remove(element.AcquireStringValue())
|
||||
} else if element.IsInt() {
|
||||
newMap.Remove(element.String())
|
||||
} else {
|
||||
return mlrval.FromNotStringError("mapselect", element)
|
||||
return mlrval.FromNotStringError("mapexcept", element)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
1
test/cases/dsl-mapsum-mapdiff-mapexcept/0033/cmd
Normal file
1
test/cases/dsl-mapsum-mapdiff-mapexcept/0033/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --from ${CASEDIR}/input --ojson put -f ${CASEDIR}/mlr
|
||||
0
test/cases/dsl-mapsum-mapdiff-mapexcept/0033/experr
Normal file
0
test/cases/dsl-mapsum-mapdiff-mapexcept/0033/experr
Normal file
23
test/cases/dsl-mapsum-mapdiff-mapexcept/0033/expout
Normal file
23
test/cases/dsl-mapsum-mapdiff-mapexcept/0033/expout
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
[
|
||||
{
|
||||
"x": "a.b.c.d.e.f",
|
||||
"y": {
|
||||
"1": "a",
|
||||
"2": "b",
|
||||
"3": "c",
|
||||
"4": "d",
|
||||
"5": "e",
|
||||
"6": "f"
|
||||
},
|
||||
"z1": {
|
||||
"2": "b",
|
||||
"4": "d",
|
||||
"6": "f"
|
||||
},
|
||||
"z2": {
|
||||
"2": "b",
|
||||
"4": "d",
|
||||
"6": "f"
|
||||
}
|
||||
}
|
||||
]
|
||||
1
test/cases/dsl-mapsum-mapdiff-mapexcept/0033/input
Normal file
1
test/cases/dsl-mapsum-mapdiff-mapexcept/0033/input
Normal file
|
|
@ -0,0 +1 @@
|
|||
x=a.b.c.d.e.f
|
||||
4
test/cases/dsl-mapsum-mapdiff-mapexcept/0033/mlr
Normal file
4
test/cases/dsl-mapsum-mapdiff-mapexcept/0033/mlr
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# Issue #1784: mapexcept with array of ints should work like mapexcept with individual ints
|
||||
$y = splitnv($x, ".");
|
||||
$z1 = mapexcept($y, 1, 3, 5);
|
||||
$z2 = mapexcept($y, [1, 3, 5]);
|
||||
Loading…
Add table
Add a link
Reference in a new issue