public void KitchenSinkExample() { var actual = RollsQuery.Execute(Db, @" SELECT { -- select a JsonPath value $.name -- call a function with a JsonPath and return the result with a custom name , isManager: any($.roles[?(@.title == 'manager')]) -- an alternate way to rename a field , $.name AS 'the dudes name' -- selecting and filtering an array , $.roles[?(@.title == 'employee' || @.title == 'manager')] -- ignoring commented lines --, $.age -- calling other functions , utc() } FROM people KEYS 1, 2, 3 WHERE starts($.name, 'Fred') OR starts($.name, 'Tim') OR starts($.name, 'Steve') AND 1=1 ORDER BY $.name DESC LIMIT 2") .ToArray(); actual.Iterate(Util.Dump).Evaluate(); Assert.Equal(2, actual.Length); }
public void MonthFunctionPositiveTest(int expected, string expression) { var actual = RollsQuery.Execute(Db, $@" SELECT MONTH({expression}) as 'X' ") .Select(j => j["X"].Value <int>()) .Single(); Assert.Equal(expected, actual); }
public void TrimFunctionPositiveTest(string expected, string expression) { var actual = RollsQuery.Execute(Db, $@" SELECT TRIM({expression}) as 'X' ") .Select(j => j["X"].Value <string>()) .Single(); Assert.Equal(expected, actual); }
public void AggregatePositiveTest(int expected, string expression) { var result = RollsQuery.Execute(Db, $@" SELECT {expression} as 'X' FROM people") .Single(); var actual = result["X"].Value <int>(); Assert.Equal(expected, actual); }
public void LimitPositiveTest(int expected, string expression) { var actual = RollsQuery.Execute(Db, $@" SELECT $ FROM people LIMIT {expression}") .Count(); Assert.Equal(expected, actual); }
public void WherePositiveTest(string expected, string expression) { var actual = String.Join(",", RollsQuery.Execute(Db, $@" SELECT $.id FROM people WHERE {expression}") .Select(j => j["id"].Value <int>())); Assert.Equal(expected, actual); }
public void SelectPositiveTest(string name, string expected, string expression) { var actual = RollsQuery.Execute(Db, $@" SELECT {{ {expression} }} FROM people KEYS 1") .Select(j => j[name].Value <string>()) .Single(); Assert.Equal(expected, actual); }
public void FirstFunctionPositiveTest(string expected, string expression) { var actual = RollsQuery.Execute(Db, $@" SELECT FIRST(SPLIT({expression})) as 'X' FROM people KEYS 1") .Select(j => j["X"].Value <string>()) .Single(); Assert.Equal(expected, actual); }
public void MultiOrderPositiveTest(string expected, string expression) { var actual = String.Join(",", RollsQuery.Execute(Db, $@" SELECT $.id FROM people ORDER BY {expression}") .Select(j => j["id"].Value <int>()) .ToArray()); Assert.Equal(expected, actual); }