MCPcopy Create free account
hub / github.com/dolthub/doltgresql / intervalAssignment

Function intervalAssignment

server/cast/interval.go:36–46  ·  view source on GitHub ↗

intervalAssignment registers all assignment casts. This comprises only the source types.

(builtInCasts map[id.Cast]casts.Cast)

Source from the content-addressed store, hash-verified

34
35// intervalAssignment registers all assignment casts. This comprises only the source types.
36func intervalAssignment(builtInCasts map[id.Cast]casts.Cast) {
37 framework.MustAddAssignmentTypeCast(builtInCasts, framework.TypeCast{
38 FromType: pgtypes.Interval,
39 ToType: pgtypes.Time,
40 Function: func(ctx *sql.Context, val any, _, targetType *pgtypes.DoltgresType) (any, error) {
41 dur := val.(duration.Duration)
42 // the month and day of the duration are excluded
43 return timeofday.FromInt(dur.Nanos() / functions.NanosPerMicro), nil
44 },
45 })
46}
47
48// intervalImplicit registers all implicit casts. This comprises only the source types.
49func intervalImplicit(builtInCasts map[id.Cast]casts.Cast) {

Callers 1

initIntervalFunction · 0.85

Calls 3

FromIntFunction · 0.92
NanosMethod · 0.80

Tested by

no test coverage detected