-
Notifications
You must be signed in to change notification settings - Fork 28
Description
While working on #102, i stumbled on some ill defined behaviour of push (which also exists in npush and push_if)
object template push;
include 'pan/functions';
"/functions/push_dml_empty/data" = {
foreach(idx;id;list(1,2,3)) {
push(id);
};
};
"/functions/push_dml_nonempty/data/0" = 0;
"/functions/push_dml_nonempty/data" = {
foreach(idx;id;list(1,2,3)) {
push(id);
};
};
current master returns
{
"functions": {
"push_empty": {
"data": [
3
]
},
"push_nonempty": {
"data": [
0,
1,
2,
3
]
}
}
}
so there is a significance difference between push depending on the the existence of SELF (the reimplementation using merge as in the PR suffers from similar yet different problems. (chagning the code and ending with SELF; gives different issues altogether, but they are still different).
my question is: how to handle this. keep the old code, but warn in the doc that push/npush/push_if have undesired sideeffects in DML blocks?
some sanity could be restored by using append in push/push_if, but there is no equivalent of append for dicts (in particular, merge with single argument to update SELF is not supported; see quattor/pan#103).