replaced uses of types.UUID with types.InlineBlob, and replace types.Bool with types.Int

This commit is contained in:
Andy Arthur
2022-06-16 09:31:00 -07:00
parent 61b8272385
commit ca1c7fa5ee
3 changed files with 22 additions and 23 deletions

View File

@@ -17,7 +17,6 @@ package encoding
import (
"context"
"errors"
"fmt"
"math/rand"
"reflect"
"strconv"
@@ -39,7 +38,7 @@ import (
func createTestSchema() schema.Schema {
columns := []schema.Column{
schema.NewColumn("id", 4, types.UUIDKind, true, schema.NotNullConstraint{}),
schema.NewColumn("id", 4, types.InlineBlobKind, true, schema.NotNullConstraint{}),
schema.NewColumn("first", 1, types.StringKind, false),
schema.NewColumn("last", 2, types.StringKind, false, schema.NotNullConstraint{}),
schema.NewColumn("age", 3, types.UintKind, false),
@@ -71,18 +70,19 @@ func TestNomsMarshalling(t *testing.T) {
t.Fatal("Failed to unmarshal types.Value as Schema")
}
if !reflect.DeepEqual(tSchema, unMarshalled) {
if !assert.Equal(t, tSchema, unMarshalled) {
t.Error("Value different after marshalling and unmarshalling.")
}
validated, err := validateUnmarshaledNomsValue(context.Background(), types.Format_Default, val)
if err != nil {
t.Fatal(fmt.Sprintf("Failed compatibility test. Schema could not be unmarshalled with mirror type, error: %s", err.Error()))
}
if !reflect.DeepEqual(tSchema, validated) {
t.Error("Value different after marshalling and unmarshalling.")
// this validation step only makes sense for Noms encoded schemas
if !types.Format_Default.UsesFlatbuffers() {
validated, err := validateUnmarshaledNomsValue(context.Background(), types.Format_Default, val)
assert.NoError(t, err,
"Failed compatibility test. Schema could not be unmarshalled with mirror type, error: %s",
err.Error())
if !assert.Equal(t, tSchema, validated) {
t.Error("Value different after marshalling and unmarshalling.")
}
}
tSuperSchema, err := schema.NewSuperSchema(tSchema)

View File

@@ -48,8 +48,7 @@ type varStringType struct {
var _ TypeInfo = (*varStringType)(nil)
var (
LegacyStringDefaultType = &varStringType{sql.CreateLongText(sql.Collation_Default)}
StringDefaultType = &varStringType{sql.MustCreateStringWithDefaults(sqltypes.VarChar, 16383)}
StringDefaultType = &varStringType{sql.MustCreateStringWithDefaults(sqltypes.VarChar, 16383)}
)
func CreateVarStringTypeFromParams(params map[string]string) (TypeInfo, error) {

View File

@@ -768,26 +768,26 @@ func TestIndexEditorCapacityExceeded(t *testing.T) {
func createTestRowData(t *testing.T, vrw types.ValueReadWriter, sch schema.Schema) (types.Map, []row.Row) {
return createTestRowDataFromTaggedValues(t, vrw, sch,
row.TaggedValues{
idTag: types.UUID(id0), firstTag: types.String("bill"), lastTag: types.String("billerson"), ageTag: types.Uint(53)},
idTag: types.InlineBlob(id0[:]), firstTag: types.String("bill"), lastTag: types.String("billerson"), ageTag: types.Uint(53)},
row.TaggedValues{
idTag: types.UUID(id1), firstTag: types.String("eric"), lastTag: types.String("ericson"), isMarriedTag: types.Bool(true), ageTag: types.Uint(21)},
idTag: types.InlineBlob(id1[:]), firstTag: types.String("eric"), lastTag: types.String("ericson"), isMarriedTag: types.Int(1), ageTag: types.Uint(21)},
row.TaggedValues{
idTag: types.UUID(id2), firstTag: types.String("john"), lastTag: types.String("johnson"), isMarriedTag: types.Bool(false), ageTag: types.Uint(53)},
idTag: types.InlineBlob(id2[:]), firstTag: types.String("john"), lastTag: types.String("johnson"), isMarriedTag: types.Int(0), ageTag: types.Uint(53)},
row.TaggedValues{
idTag: types.UUID(id3), firstTag: types.String("robert"), lastTag: types.String("robertson"), ageTag: types.Uint(36)},
idTag: types.InlineBlob(id3[:]), firstTag: types.String("robert"), lastTag: types.String("robertson"), ageTag: types.Uint(36)},
)
}
func createUpdatedTestRowData(t *testing.T, vrw types.ValueReadWriter, sch schema.Schema) (types.Map, []row.Row) {
return createTestRowDataFromTaggedValues(t, vrw, sch,
row.TaggedValues{
idTag: types.UUID(id0), firstTag: types.String("jack"), lastTag: types.String("space"), ageTag: types.Uint(20)},
idTag: types.InlineBlob(id0[:]), firstTag: types.String("jack"), lastTag: types.String("space"), ageTag: types.Uint(20)},
row.TaggedValues{
idTag: types.UUID(id1), firstTag: types.String("rick"), lastTag: types.String("drive"), isMarriedTag: types.Bool(false), ageTag: types.Uint(21)},
idTag: types.InlineBlob(id1[:]), firstTag: types.String("rick"), lastTag: types.String("drive"), isMarriedTag: types.Int(0), ageTag: types.Uint(21)},
row.TaggedValues{
idTag: types.UUID(id2), firstTag: types.String("tyler"), lastTag: types.String("eat"), isMarriedTag: types.Bool(true), ageTag: types.Uint(22)},
idTag: types.InlineBlob(id2[:]), firstTag: types.String("tyler"), lastTag: types.String("eat"), isMarriedTag: types.Int(1), ageTag: types.Uint(22)},
row.TaggedValues{
idTag: types.UUID(id3), firstTag: types.String("moore"), lastTag: types.String("walk"), ageTag: types.Uint(23)},
idTag: types.InlineBlob(id3[:]), firstTag: types.String("moore"), lastTag: types.String("walk"), ageTag: types.Uint(23)},
)
}
@@ -814,10 +814,10 @@ func createTestRowDataFromTaggedValues(t *testing.T, vrw types.ValueReadWriter,
func createTestSchema(t *testing.T) schema.Schema {
colColl := schema.NewColCollection(
schema.NewColumn("id", idTag, types.UUIDKind, true, schema.NotNullConstraint{}),
schema.NewColumn("id", idTag, types.InlineBlobKind, true, schema.NotNullConstraint{}),
schema.NewColumn("first", firstTag, types.StringKind, false, schema.NotNullConstraint{}),
schema.NewColumn("last", lastTag, types.StringKind, false, schema.NotNullConstraint{}),
schema.NewColumn("is_married", isMarriedTag, types.BoolKind, false),
schema.NewColumn("is_married", isMarriedTag, types.IntKind, false),
schema.NewColumn("age", ageTag, types.UintKind, false),
schema.NewColumn("empty", emptyTag, types.IntKind, false),
)