numericImplicit registers all implicit casts. This comprises only the source types.
(builtInCasts map[id.Cast]casts.Cast)
| 73 | |
| 74 | // numericImplicit registers all implicit casts. This comprises only the source types. |
| 75 | func numericImplicit(builtInCasts map[id.Cast]casts.Cast) { |
| 76 | framework.MustAddImplicitTypeCast(builtInCasts, framework.TypeCast{ |
| 77 | FromType: pgtypes.Numeric, |
| 78 | ToType: pgtypes.Float32, |
| 79 | Function: func(ctx *sql.Context, val any, _, targetType *pgtypes.DoltgresType) (any, error) { |
| 80 | d := val.(*apd.Decimal) |
| 81 | f, _ := d.Float64() |
| 82 | return float32(f), nil |
| 83 | }, |
| 84 | }) |
| 85 | framework.MustAddImplicitTypeCast(builtInCasts, framework.TypeCast{ |
| 86 | FromType: pgtypes.Numeric, |
| 87 | ToType: pgtypes.Float64, |
| 88 | Function: func(ctx *sql.Context, val any, _, targetType *pgtypes.DoltgresType) (any, error) { |
| 89 | d := val.(*apd.Decimal) |
| 90 | f, _ := d.Float64() |
| 91 | return f, nil |
| 92 | }, |
| 93 | }) |
| 94 | framework.MustAddImplicitTypeCast(builtInCasts, framework.TypeCast{ |
| 95 | FromType: pgtypes.Numeric, |
| 96 | ToType: pgtypes.Numeric, |
| 97 | Function: func(ctx *sql.Context, val any, _, targetType *pgtypes.DoltgresType) (any, error) { |
| 98 | return pgtypes.GetNumericValueWithTypmod(val.(*apd.Decimal), targetType.GetAttTypMod()) |
| 99 | }, |
| 100 | }) |
| 101 | } |
no test coverage detected