timestampAssignment registers all assignment casts. This comprises only the source types.
(builtInCasts map[id.Cast]casts.Cast)
| 35 | |
| 36 | // timestampAssignment registers all assignment casts. This comprises only the source types. |
| 37 | func 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. |
| 59 | func timestampImplicit(builtInCasts map[id.Cast]casts.Cast) { |
no test coverage detected