Add Postgres DATE_TRUNC function

This commit is contained in:
Branislav Lazic 2024-09-20 09:47:40 +02:00
parent b835e25665
commit b25b2aa213
2 changed files with 21 additions and 1 deletions

View file

@ -1,6 +1,8 @@
package postgres
import "testing"
import (
"testing"
)
func TestROW(t *testing.T) {
assertSerialize(t, ROW(SELECT(Int(1))), `ROW((
@ -10,3 +12,12 @@ func TestROW(t *testing.T) {
SELECT $2
), $3)`)
}
func TestDATE_TRUNC(t *testing.T) {
assertSerialize(t, DATE_TRUNC(YEAR, NOW()), "DATE_TRUNC('YEAR', NOW())")
assertSerialize(
t,
DATE_TRUNC(DAY, NOW().ADD(INTERVAL(1, HOUR)), "Australia/Sydney"),
"DATE_TRUNC('DAY', NOW() + INTERVAL '1 HOUR', 'Australia/Sydney')",
)
}