Fix some errors with the Map function
Signed-off-by: davidarendsen <davidarendsen@hey.com>
This commit is contained in:
parent
7430472c8c
commit
0a4da04e58
2 changed files with 9 additions and 7 deletions
|
|
@ -10,14 +10,16 @@ class Map extends Base
|
|||
|
||||
public static function with(string $name, string $content): Map
|
||||
{
|
||||
self::$string = 'r with ' . $name . ': ' . $content;
|
||||
return new self();
|
||||
$object = new self();
|
||||
$object::$string = 'r with ' . $name . ': ' . $content;
|
||||
return $object;
|
||||
}
|
||||
|
||||
public static function columns(array $columns)
|
||||
{
|
||||
self::$string = new FieldRecordType($columns);
|
||||
return new self();
|
||||
$object = new self();
|
||||
$object::$string = new FieldRecordType($columns);
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ final class MapFunctionTest extends TestCase
|
|||
$expression = new Map(MapExpression::columns([
|
||||
'time' => 'r._time',
|
||||
'source' => 'r.tag',
|
||||
'alert' => SelectionExpression::if('r._value > 10')->then(true)->else(false),
|
||||
'test' => SelectionExpression::if('r._value > 10')->then('yes')->else('no')
|
||||
]));
|
||||
'alert' => SelectionExpression::if('r._value > 10')->then(true)->else(false)->__toString(),
|
||||
'test' => SelectionExpression::if('r._value > 10')->then('yes')->else('no')->__toString()
|
||||
])->__toString());
|
||||
|
||||
$query = '|> map(fn: (r) => ({ {time: r._time, source: r.tag, ' .
|
||||
'alert: if r._value > 10 then true else false, ' .
|
||||
|
|
|
|||
Loading…
Add table
editor.link_modal.header
Reference in a new issue