Added unixEpochNanoTo and unixEpochNanoFrom macros to postgresql

This commit is contained in:
Ander Arguiñano
2019-01-03 21:31:47 +01:00
parent 4d8d2a9690
commit 9105625f24
2 changed files with 17 additions and 0 deletions

View File

@@ -121,6 +121,19 @@ func TestMacroEngine(t *testing.T) {
So(sql, ShouldEqual, fmt.Sprintf("select time >= %d AND time <= %d", from.UnixNano(), to.UnixNano()))
})
Convey("interpolate __unixEpochNanoFrom function", func() {
sql, err := engine.Interpolate(query, timeRange, "select $__unixEpochNanoFrom()")
So(err, ShouldBeNil)
So(sql, ShouldEqual, fmt.Sprintf("select '%d'", from.UnixNano()))
})
Convey("interpolate __unixEpochNanoTo function", func() {
sql, err := engine.Interpolate(query, timeRange, "select $__unixEpochNanoTo()")
So(err, ShouldBeNil)
So(sql, ShouldEqual, fmt.Sprintf("select '%d'", to.UnixNano()))
})
Convey("interpolate __unixEpochGroup function", func() {