diff --git a/go/libraries/doltcore/schema/schema_impl.go b/go/libraries/doltcore/schema/schema_impl.go index 42622e05d2..9fd64f58c3 100644 --- a/go/libraries/doltcore/schema/schema_impl.go +++ b/go/libraries/doltcore/schema/schema_impl.go @@ -199,7 +199,7 @@ func ValidateForInsert(allCols *ColCollection) error { } colNames[col.Name] = true - if col.AutoIncrement && !isAutoIncrementKind(col.Kind) { + if col.AutoIncrement && !(isAutoIncrementKind(col.Kind) || isAutoIncrementType(col.TypeInfo.ToSqlType().Type())) { return true, ErrNonAutoIncType } @@ -250,6 +250,19 @@ func isAutoIncrementKind(k types.NomsKind) bool { return k == types.IntKind || k == types.UintKind || k == types.FloatKind } +// isAutoIncrementType returns true is |t| is a numeric type. +// This is an alternative way for the numeric type check. +func isAutoIncrementType(t query.Type) bool { + switch t { + case query.Type_INT8, query.Type_INT16, query.Type_INT24, query.Type_INT32, query.Type_INT64, + query.Type_UINT8, query.Type_UINT16, query.Type_UINT24, query.Type_UINT32, query.Type_UINT64, + query.Type_FLOAT32, query.Type_FLOAT64, query.Type_DECIMAL: + return true + default: + return false + } +} + // UnkeyedSchemaFromCols creates a schema without any primary keys to be used for displaying to users, tests, etc. Such // unkeyed schemas are not suitable to be inserted into storage. func UnkeyedSchemaFromCols(allCols *ColCollection) Schema {