Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

feat: Always use BigInt #321

Merged
merged 1 commit into from
Jun 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions provider/schema/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,8 @@ func (v ValueType) String() string {
switch v {
case TypeBool:
return "TypeBool"
case TypeBigInt:
case TypeInt, TypeBigInt, TypeSmallInt:
return "TypeBigInt"
case TypeSmallInt:
return "TypeSmallInt"
case TypeInt:
return "TypeInt"
case TypeFloat:
return "TypeFloat"
case TypeUUID:
Expand Down Expand Up @@ -141,16 +137,13 @@ func (v ValueType) String() string {
}
}

// ValueTypeFromString this function is mainly used by https://github.com/cloudquery/cq-gen
func ValueTypeFromString(s string) ValueType {
switch strings.ToLower(s) {
case "bool", "TypeBool":
return TypeBool
case "int", "TypeInt":
return TypeInt
case "bigint", "TypeBigInt":
case "int", "TypeInt", "bigint", "TypeBigInt", "smallint", "TypeSmallInt":
return TypeBigInt
case "smallint", "TypeSmallInt":
return TypeSmallInt
case "float", "TypeFloat":
return TypeFloat
case "uuid", "TypeUUID":
Expand Down Expand Up @@ -214,12 +207,9 @@ func (c Column) checkType(v interface{}) bool {
}

switch val := v.(type) {
case int8, *int8, uint8, *uint8, int16, *int16:
return c.Type == TypeSmallInt
case uint16, int32, *int32:
return c.Type == TypeInt
case int, *int, uint32, *uint32, int64, *int64:
return c.Type == TypeBigInt || c.Type == TypeInt
case int8, *int8, uint8, *uint8, int16, *int16, uint16, *uint16, int32, *int32, int, *int, uint32, *uint32, int64, *int64:
// TODO: Deprecate all Int Types in favour of BigInt
return c.Type == TypeBigInt || c.Type == TypeSmallInt || c.Type == TypeInt
case []byte:
if c.Type == TypeUUID {
if _, err := uuid.FromBytes(val); err != nil {
Expand Down