Skip to content

Commit 78465f7

Browse files
asmyasnikovImpressionableRaccoon
authored andcommitted
* Added table/types.IsOptional() helper
1 parent c636165 commit 78465f7

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* Added `table/types.IsOptional()` helper
2+
13
## v3.48.2
24
* Refactored tests
35

table/types/cast.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ func CastTo(v Value, dst interface{}) error {
1818
return value.CastTo(v, dst)
1919
}
2020

21+
func IsOptional(t Type) (isOptional bool, innerType Type) {
22+
if optionalType, isOptional := t.(interface {
23+
IsOptional()
24+
InnerType() Type
25+
}); isOptional {
26+
return isOptional, optionalType.InnerType()
27+
}
28+
return false, nil
29+
}
30+
2131
// ToDecimal returns Decimal struct from abstract Value
2232
func ToDecimal(v Value) (*Decimal, error) {
2333
if valuer, isDecimalValuer := v.(value.DecimalValuer); isDecimalValuer {

0 commit comments

Comments
 (0)