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

Function timestampAssignment

server/cast/timestamp.go:37–56  ·  view source on GitHub ↗

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

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

Source from the content-addressed store, hash-verified

35
36// timestampAssignment registers all assignment casts. This comprises only the source types.
37func timestampAssignment(builtInCasts map[id.Cast]casts.Cast) {
38 framework.MustAddAssignmentTypeCast(builtInCasts, framework.TypeCast{
39 FromType: pgtypes.Timestamp,
40 ToType: pgtypes.Date,
41 Function: func(ctx *sql.Context, val any, _, targetType *pgtypes.DoltgresType) (any, error) {
42 d, err := pgdate.MakeDateFromTime(val.(time.Time))
43 if err != nil {
44 return nil, err
45 }
46 return d.ToTime()
47 },
48 })
49 framework.MustAddAssignmentTypeCast(builtInCasts, framework.TypeCast{
50 FromType: pgtypes.Timestamp,
51 ToType: pgtypes.Time,
52 Function: func(ctx *sql.Context, val any, _, targetType *pgtypes.DoltgresType) (any, error) {
53 return timeofday.FromTime(val.(time.Time)), nil
54 },
55 })
56}
57
58// timestampImplicit registers all implicit casts. This comprises only the source types.
59func timestampImplicit(builtInCasts map[id.Cast]casts.Cast) {

Callers 1

initTimestampFunction · 0.85

Calls 4

MakeDateFromTimeFunction · 0.92
FromTimeFunction · 0.92
ToTimeMethod · 0.45

Tested by

no test coverage detected