Add support for EXTRACT time/date function.
This commit is contained in:
parent
bc776f947b
commit
2101088d0e
15 changed files with 222 additions and 14 deletions
|
|
@ -1,6 +1,8 @@
|
|||
package postgres
|
||||
|
||||
import "github.com/go-jet/jet/v2/internal/jet"
|
||||
import (
|
||||
"github.com/go-jet/jet/v2/internal/jet"
|
||||
)
|
||||
|
||||
// This functions can be used, instead of its method counterparts, to have a better indentation of a complex condition
|
||||
// in the Go code and in the generated SQL.
|
||||
|
|
@ -279,6 +281,26 @@ var TO_TIMESTAMP = jet.TO_TIMESTAMP
|
|||
|
||||
//----------------- Date/Time Functions and Operators ------------//
|
||||
|
||||
// Additional time unit types for EXTRACT function
|
||||
const (
|
||||
DOW unit = MILLENNIUM + 1 + iota
|
||||
DOY
|
||||
EPOCH
|
||||
ISODOW
|
||||
ISOYEAR
|
||||
JULIAN
|
||||
QUARTER
|
||||
TIMEZONE
|
||||
TIMEZONE_HOUR
|
||||
TIMEZONE_MINUTE
|
||||
)
|
||||
|
||||
// EXTRACT function retrieves subfields such as year or hour from date/time values
|
||||
// EXTRACT(DAY, User.CreatedAt)
|
||||
func EXTRACT(field unit, from Expression) FloatExpression {
|
||||
return FloatExp(jet.EXTRACT(unitToString(field), from))
|
||||
}
|
||||
|
||||
// CURRENT_DATE returns current date
|
||||
var CURRENT_DATE = jet.CURRENT_DATE
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue