Add postgres interval cast.

This commit is contained in:
go-jet 2019-12-07 13:52:51 +01:00
parent 4a3579e7f9
commit a2fbc4f53a
4 changed files with 56 additions and 20 deletions

View file

@ -129,3 +129,22 @@ func unitToString(unit quantityAndUnit) string {
panic("jet: invalid INTERVAL unit type")
}
}
//---------------------------------------------------//
type intervalWrapper struct {
jet.IsInterval
Expression
}
func newIntervalExpressionWrap(expression Expression) IntervalExpression {
intervalWrap := intervalWrapper{Expression: expression}
return &intervalWrap
}
// IntervalExp is interval expression wrapper around arbitrary expression.
// Allows go compiler to see any expression as interval expression.
// Does not add sql cast to generated sql builder output.
func IntervalExp(expression Expression) IntervalExpression {
return newIntervalExpressionWrap(expression)
}