mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
FEATURE: Add a module for stripping NULL fields from a tuple.
This commit is contained in:
parent
e838554fff
commit
b9b30a4bd1
@ -14,4 +14,9 @@ assert t.equal{
|
|||||||
assert t.equal{
|
assert t.equal{
|
||||||
left = tpl.iter{tpl={foo=1, bar=2}}.result,
|
left = tpl.iter{tpl={foo=1, bar=2}}.result,
|
||||||
right = [["foo", 1], ["bar", 2]],
|
right = [["foo", 1], ["bar", 2]],
|
||||||
|
};
|
||||||
|
|
||||||
|
assert t.equal{
|
||||||
|
left = tpl.strip_nulls{tpl={foo="bar", bar=NULL}}.result,
|
||||||
|
right = {foo="bar"},
|
||||||
};
|
};
|
@ -29,4 +29,14 @@ let iter = module{
|
|||||||
};
|
};
|
||||||
|
|
||||||
let result = reduce reducer.result [], (mod.tpl);
|
let result = reduce reducer.result [], (mod.tpl);
|
||||||
|
};
|
||||||
|
|
||||||
|
let strip_nulls = module{
|
||||||
|
tpl = NULL,
|
||||||
|
} => {
|
||||||
|
let filterer = macro(name, value) => {
|
||||||
|
result = value != NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
let result = filter filterer.result (mod.tpl);
|
||||||
};
|
};
|
Loading…
x
Reference in New Issue
Block a user