From 553508378d98a69e09abaf92ade5e2bf35a9d364 Mon Sep 17 00:00:00 2001 From: AndrewSisley Date: Wed, 7 Feb 2024 11:45:34 -0500 Subject: [PATCH] feat: Replace FieldDescription.RelationType with IsPrimary (#2288) ## Relevant issue(s) Resolves #2287 #1772 ## Description Replaces `FieldDescription.RelationType` with an `IsPrimary` boolean. One notable effect of this that may not be easily visible in the code-diff is that the schema ID will not change depending on whether it is the primary side of a one-one or on the one side of a one-many - now the schema only cares about the shape of the data, not what is on the other side of the relationship. --- client/descriptions.go | 32 +-- db/collection.go | 98 ++----- db/collection_update.go | 4 +- db/errors.go | 22 -- .../i2288-relation-type-is-primary.md | 3 + planner/mapper/mapper.go | 4 +- planner/type_join.go | 14 +- request/graphql/schema/collection.go | 33 +-- request/graphql/schema/descriptions_test.go | 101 ++++--- request/graphql/schema/relations.go | 144 +++------- request/graphql/schema/relations_test.go | 86 ------ tests/gen/gen_auto.go | 2 +- tests/gen/gen_auto_configurator.go | 4 +- tests/gen/gen_auto_test.go | 22 +- .../events/simple/with_update_test.go | 4 +- .../mutation/create/with_version_test.go | 2 +- .../simple/replicator/with_create_test.go | 4 +- .../integration/query/commits/simple_test.go | 30 +-- .../query/commits/with_cid_test.go | 8 +- .../query/commits/with_depth_test.go | 34 +-- .../query/commits/with_doc_id_cid_test.go | 4 +- .../query/commits/with_doc_id_count_test.go | 6 +- .../query/commits/with_doc_id_field_test.go | 4 +- .../commits/with_doc_id_limit_offset_test.go | 4 +- .../query/commits/with_doc_id_limit_test.go | 4 +- .../with_doc_id_order_limit_offset_test.go | 4 +- .../query/commits/with_doc_id_order_test.go | 66 ++--- .../query/commits/with_doc_id_test.go | 46 ++-- .../commits/with_doc_id_typename_test.go | 6 +- .../query/commits/with_field_test.go | 8 +- .../query/commits/with_group_test.go | 16 +- .../latest_commits/with_doc_id_field_test.go | 8 +- .../query/latest_commits/with_doc_id_test.go | 10 +- .../query/one_to_many/with_cid_doc_id_test.go | 8 +- .../query/simple/with_cid_doc_id_test.go | 16 +- .../query/simple/with_version_test.go | 14 +- tests/integration/schema/crdt_type_test.go | 4 +- tests/integration/schema/get_schema_test.go | 72 ++--- .../schema/migrations/query/simple_test.go | 44 +-- .../migrations/query/with_doc_id_test.go | 8 +- .../schema/migrations/query/with_p2p_test.go | 12 +- .../migrations/query/with_restart_test.go | 4 +- .../migrations/query/with_set_default_test.go | 12 +- .../schema/migrations/query/with_txn_test.go | 8 +- .../migrations/query/with_update_test.go | 8 +- .../schema/migrations/simple_test.go | 8 +- tests/integration/schema/simple_test.go | 2 +- .../updates/add/field/create_update_test.go | 8 +- .../field/kind/foreign_object_array_test.go | 250 +++--------------- .../add/field/kind/foreign_object_test.go | 232 ++++------------ .../schema/updates/add/field/simple_test.go | 8 +- .../schema/updates/move/simple_test.go | 2 +- .../updates/remove/fields/simple_test.go | 33 +-- .../schema/updates/test/field/simple_test.go | 4 +- .../schema/with_update_set_default_test.go | 4 +- tests/predefined/gen_predefined.go | 6 +- tests/predefined/gen_predefined_test.go | 5 +- 57 files changed, 496 insertions(+), 1113 deletions(-) create mode 100644 docs/data_format_changes/i2288-relation-type-is-primary.md delete mode 100644 request/graphql/schema/relations_test.go diff --git a/client/descriptions.go b/client/descriptions.go index 2cc66de85b..80f08b6a1c 100644 --- a/client/descriptions.go +++ b/client/descriptions.go @@ -80,7 +80,9 @@ func (col CollectionDescription) GetFieldByRelation( schema *SchemaDescription, ) (FieldDescription, bool) { for _, field := range schema.Fields { - if field.RelationName == relationName && !(col.Name.Value() == otherCollectionName && otherFieldName == field.Name) { + if field.RelationName == relationName && + !(col.Name.Value() == otherCollectionName && otherFieldName == field.Name) && + field.Kind != FieldKind_DocID { return field, true } } @@ -250,18 +252,6 @@ var FieldKindStringToEnumMapping = map[string]FieldKind{ // RelationType describes the type of relation between two types. type RelationType uint8 -// Note: These values are serialized and persisted in the database, avoid modifying existing values -const ( - Relation_Type_ONE RelationType = 1 // 0b0000 0001 - Relation_Type_MANY RelationType = 2 // 0b0000 0010 - Relation_Type_ONEONE RelationType = 4 // 0b0000 0100 - Relation_Type_ONEMANY RelationType = 8 // 0b0000 1000 - Relation_Type_MANYMANY RelationType = 16 // 0b0001 0000 - _ RelationType = 32 // 0b0010 0000 - Relation_Type_INTERNAL_ID RelationType = 64 // 0b0100 0000 - Relation_Type_Primary RelationType = 128 // 0b1000 0000 Primary reference entity on relation -) - // FieldID is a unique identifier for a field in a schema. type FieldID uint32 @@ -302,14 +292,7 @@ type FieldDescription struct { // It is currently immutable. Typ CType - // RelationType contains the relationship type if this field is a relation field. Otherwise this - // will be empty. - RelationType RelationType -} - -// IsInternal returns true if this field is internally generated. -func (f FieldDescription) IsInternal() bool { - return (f.Name == request.DocIDFieldName) || f.RelationType&Relation_Type_INTERNAL_ID != 0 + IsPrimaryRelation bool } // IsObject returns true if this field is an object type. @@ -323,14 +306,9 @@ func (f FieldDescription) IsObjectArray() bool { return (f.Kind == FieldKind_FOREIGN_OBJECT_ARRAY) } -// IsPrimaryRelation returns true if this field is a relation, and is the primary side. -func (f FieldDescription) IsPrimaryRelation() bool { - return f.RelationType > 0 && f.RelationType&Relation_Type_Primary != 0 -} - // IsRelation returns true if this field is a relation. func (f FieldDescription) IsRelation() bool { - return f.RelationType > 0 + return f.RelationName != "" } // IsArray returns true if this field is an array type which includes inline arrays as well diff --git a/db/collection.go b/db/collection.go index 50a8acb4f6..639a53a341 100644 --- a/db/collection.go +++ b/db/collection.go @@ -169,13 +169,12 @@ func (db *db) updateSchema( } for _, field := range schema.Fields { - if field.RelationType.IsSet(client.Relation_Type_ONE) { + if field.Kind == client.FieldKind_FOREIGN_OBJECT { idFieldName := field.Name + "_id" if _, ok := schema.GetField(idFieldName); !ok { schema.Fields = append(schema.Fields, client.FieldDescription{ Name: idFieldName, Kind: client.FieldKind_DocID, - RelationType: client.Relation_Type_INTERNAL_ID, RelationName: field.RelationName, }) } @@ -316,40 +315,11 @@ func validateUpdateSchemaFields( return false, NewErrSchemaNotFound(proposedField.Name, proposedField.Schema) } - if proposedField.Kind == client.FieldKind_FOREIGN_OBJECT { - if !proposedField.RelationType.IsSet(client.Relation_Type_ONE) || - !(proposedField.RelationType.IsSet(client.Relation_Type_ONEONE) || - proposedField.RelationType.IsSet(client.Relation_Type_ONEMANY)) { - return false, NewErrRelationalFieldInvalidRelationType( - proposedField.Name, - fmt.Sprintf( - "%v and %v or %v, with optionally %v", - client.Relation_Type_ONE, - client.Relation_Type_ONEONE, - client.Relation_Type_ONEMANY, - client.Relation_Type_Primary, - ), - proposedField.RelationType, - ) - } - } - - if proposedField.Kind == client.FieldKind_FOREIGN_OBJECT_ARRAY { - if !proposedField.RelationType.IsSet(client.Relation_Type_MANY) || - !proposedField.RelationType.IsSet(client.Relation_Type_ONEMANY) { - return false, NewErrRelationalFieldInvalidRelationType( - proposedField.Name, - client.Relation_Type_MANY|client.Relation_Type_ONEMANY, - proposedField.RelationType, - ) - } - } - if proposedField.RelationName == "" { return false, NewErrRelationalFieldMissingRelationName(proposedField.Name) } - if proposedField.RelationType.IsSet(client.Relation_Type_Primary) { + if proposedField.IsPrimaryRelation { if proposedField.Kind == client.FieldKind_FOREIGN_OBJECT_ARRAY { return false, NewErrPrimarySideOnMany(proposedField.Name) } @@ -363,14 +333,6 @@ func validateUpdateSchemaFields( return false, NewErrRelationalFieldIDInvalidType(idField.Name, client.FieldKind_DocID, idField.Kind) } - if idField.RelationType != client.Relation_Type_INTERNAL_ID { - return false, NewErrRelationalFieldInvalidRelationType( - idField.Name, - client.Relation_Type_INTERNAL_ID, - idField.RelationType, - ) - } - if idField.RelationName == "" { return false, NewErrRelationalFieldMissingRelationName(idField.Name) } @@ -381,7 +343,7 @@ func validateUpdateSchemaFields( var relatedField client.FieldDescription for _, field := range relatedDesc.Fields { if field.RelationName == proposedField.RelationName && - !field.RelationType.IsSet(client.Relation_Type_INTERNAL_ID) && + field.Kind != client.FieldKind_DocID && !(relatedDesc.Name == proposedDesc.Name && field.Name == proposedField.Name) { relatedFieldFound = true relatedField = field @@ -393,43 +355,13 @@ func validateUpdateSchemaFields( return false, client.NewErrRelationOneSided(proposedField.Name, proposedField.Schema) } - if !(proposedField.RelationType.IsSet(client.Relation_Type_Primary) || - relatedField.RelationType.IsSet(client.Relation_Type_Primary)) { + if !(proposedField.IsPrimaryRelation || relatedField.IsPrimaryRelation) { return false, NewErrPrimarySideNotDefined(proposedField.RelationName) } - if proposedField.RelationType.IsSet(client.Relation_Type_Primary) && - relatedField.RelationType.IsSet(client.Relation_Type_Primary) { + if proposedField.IsPrimaryRelation && relatedField.IsPrimaryRelation { return false, NewErrBothSidesPrimary(proposedField.RelationName) } - - if proposedField.RelationType.IsSet(client.Relation_Type_ONEONE) && - relatedField.Kind != client.FieldKind_FOREIGN_OBJECT { - return false, NewErrRelatedFieldKindMismatch( - proposedField.RelationName, - client.FieldKind_FOREIGN_OBJECT, - relatedField.Kind, - ) - } - - if proposedField.RelationType.IsSet(client.Relation_Type_ONEMANY) && - proposedField.Kind == client.FieldKind_FOREIGN_OBJECT && - relatedField.Kind != client.FieldKind_FOREIGN_OBJECT_ARRAY { - return false, NewErrRelatedFieldKindMismatch( - proposedField.RelationName, - client.FieldKind_FOREIGN_OBJECT_ARRAY, - relatedField.Kind, - ) - } - - if proposedField.RelationType.IsSet(client.Relation_Type_ONEONE) && - !relatedField.RelationType.IsSet(client.Relation_Type_ONEONE) { - return false, NewErrRelatedFieldRelationTypeMismatch( - proposedField.RelationName, - client.Relation_Type_ONEONE, - relatedField.RelationType, - ) - } } if _, isDuplicate := newFieldNames[proposedField.Name]; isDuplicate { @@ -1099,7 +1031,7 @@ func (c *collection) validateOneToOneLinkDoesntAlreadyExist( fieldDescription client.FieldDescription, value any, ) error { - if !fieldDescription.RelationType.IsSet(client.Relation_Type_INTERNAL_ID) { + if fieldDescription.Kind != client.FieldKind_DocID { return nil } @@ -1111,7 +1043,23 @@ func (c *collection) validateOneToOneLinkDoesntAlreadyExist( if !ok { return client.NewErrFieldNotExist(strings.TrimSuffix(fieldDescription.Name, request.RelatedObjectID)) } - if !objFieldDescription.RelationType.IsSet(client.Relation_Type_ONEONE) { + if objFieldDescription.Kind != client.FieldKind_FOREIGN_OBJECT { + return nil + } + + otherCol, err := c.db.getCollectionByName(ctx, txn, objFieldDescription.Schema) + if err != nil { + return err + } + otherSchema := otherCol.Schema() + otherObjFieldDescription, _ := otherCol.Description().GetFieldByRelation( + fieldDescription.RelationName, + c.Name().Value(), + objFieldDescription.Name, + &otherSchema, + ) + if otherObjFieldDescription.Kind != client.FieldKind_FOREIGN_OBJECT { + // If the other field is not an object field then this is not a one to one relation and we can continue return nil } diff --git a/db/collection_update.go b/db/collection_update.go index f4fc1eef6e..58e6e9086f 100644 --- a/db/collection_update.go +++ b/db/collection_update.go @@ -292,14 +292,14 @@ func (c *collection) updateWithFilter( // isSecondaryIDField returns true if the given field description represents a secondary relation field ID. func (c *collection) isSecondaryIDField(fieldDesc client.FieldDescription) (client.FieldDescription, bool) { - if fieldDesc.RelationType != client.Relation_Type_INTERNAL_ID { + if fieldDesc.RelationName == "" || fieldDesc.Kind != client.FieldKind_DocID { return client.FieldDescription{}, false } relationFieldDescription, valid := c.Schema().GetField( strings.TrimSuffix(fieldDesc.Name, request.RelatedObjectID), ) - return relationFieldDescription, valid && !relationFieldDescription.IsPrimaryRelation() + return relationFieldDescription, valid && !relationFieldDescription.IsPrimaryRelation } // patchPrimaryDoc patches the (primary) document linked to from the document of the given DocID via the diff --git a/db/errors.go b/db/errors.go index 9b1f414fd6..37f267412c 100644 --- a/db/errors.go +++ b/db/errors.go @@ -253,15 +253,6 @@ func NewErrRelationalFieldMissingSchema(name string, kind client.FieldKind) erro ) } -func NewErrRelationalFieldInvalidRelationType(name string, expected any, actual client.RelationType) error { - return errors.New( - errRelationalFieldInvalidRelationType, - errors.NewKV("Field", name), - errors.NewKV("Expected", expected), - errors.NewKV("Actual", actual), - ) -} - func NewErrRelationalFieldMissingIDField(name string, expectedName string) error { return errors.New( errRelationalFieldMissingIDField, @@ -307,19 +298,6 @@ func NewErrRelatedFieldKindMismatch(relationName string, expected client.FieldKi ) } -func NewErrRelatedFieldRelationTypeMismatch( - relationName string, - expected client.RelationType, - actual client.RelationType, -) error { - return errors.New( - errRelatedFieldRelationTypeMismatch, - errors.NewKV("RelationName", relationName), - errors.NewKV("Expected", expected), - errors.NewKV("Actual", actual), - ) -} - func NewErrRelationalFieldIDInvalidType(name string, expected, actual client.FieldKind) error { return errors.New( errRelationalFieldIDInvalidType, diff --git a/docs/data_format_changes/i2288-relation-type-is-primary.md b/docs/data_format_changes/i2288-relation-type-is-primary.md new file mode 100644 index 0000000000..ba6a95c653 --- /dev/null +++ b/docs/data_format_changes/i2288-relation-type-is-primary.md @@ -0,0 +1,3 @@ +# ReplaceRelation type with IsPrimary + +The FieldDescription struct has changed, this has affected schema version ids, and commit cids of documents as they are based off the schema version id. diff --git a/planner/mapper/mapper.go b/planner/mapper/mapper.go index 06772be487..0ea6b1b622 100644 --- a/planner/mapper/mapper.go +++ b/planner/mapper/mapper.go @@ -717,7 +717,7 @@ func getCollectionName( } hostFieldDesc, parentHasField := parentCollection.Schema().GetField(selectRequest.Name) - if parentHasField && hostFieldDesc.RelationType != 0 { + if parentHasField && hostFieldDesc.RelationName != "" { // If this field exists on the parent, and it is a child object // then this collection name is the collection name of the child. return hostFieldDesc.Schema, nil @@ -1018,7 +1018,7 @@ func resolveSecondaryRelationIDs( continue } - if !fieldDesc.RelationType.IsSet(client.Relation_Type_INTERNAL_ID) { + if fieldDesc.Kind != client.FieldKind_DocID { continue } diff --git a/planner/type_join.go b/planner/type_join.go index 9d9a27b969..a39af2fae7 100644 --- a/planner/type_join.go +++ b/planner/type_join.go @@ -20,7 +20,6 @@ import ( "github.com/sourcenetwork/defradb/db/base" "github.com/sourcenetwork/defradb/planner/filter" "github.com/sourcenetwork/defradb/planner/mapper" - "github.com/sourcenetwork/defradb/request/graphql/schema" ) /* @@ -86,10 +85,9 @@ func (p *Planner) makeTypeIndexJoin( return nil, client.NewErrFieldNotExist(subType.Name) } - meta := typeFieldDesc.RelationType - if schema.IsOne(meta) { // One-to-One, or One side of One-to-Many + if typeFieldDesc.Kind == client.FieldKind_FOREIGN_OBJECT { // One-to-One, or One side of One-to-Many joinPlan, err = p.makeTypeJoinOne(parent, source, subType) - } else if schema.IsOneToMany(meta) { // Many side of One-to-Many + } else if typeFieldDesc.Kind == client.FieldKind_FOREIGN_OBJECT_ARRAY { // Many side of One-to-Many joinPlan, err = p.makeTypeJoinMany(parent, source, subType) } else { // more to come, Many-to-Many, Embedded? return nil, ErrUnknownRelationType @@ -249,10 +247,6 @@ func (p *Planner) makeTypeJoinOne( return nil, client.NewErrFieldNotExist(subType.Name) } - // determine relation direction (primary or secondary?) - // check if the field we're querying is the primary side of the relation - isPrimary := subTypeFieldDesc.RelationType.IsSet(client.Relation_Type_Primary) - subTypeCol, err := p.db.GetCollectionByName(p.ctx, subType.CollectionName) if err != nil { return nil, err @@ -270,7 +264,7 @@ func (p *Planner) makeTypeJoinOne( } var secondaryFieldIndex immutable.Option[int] - if !isPrimary { + if !subTypeFieldDesc.IsPrimaryRelation { idFieldName := subTypeFieldDesc.Name + request.RelatedObjectID secondaryFieldIndex = immutable.Some( parent.documentMapping.FirstIndexOfName(idFieldName), @@ -292,7 +286,7 @@ func (p *Planner) makeTypeJoinOne( subSelect: subType, rootName: subTypeField.Name, subTypeName: subType.Name, - isSecondary: !isPrimary, + isSecondary: !subTypeFieldDesc.IsPrimaryRelation, secondaryFieldIndex: secondaryFieldIndex, secondaryFetchLimit: 1, dir: dir, diff --git a/request/graphql/schema/collection.go b/request/graphql/schema/collection.go index a1d5bd5c54..e7444b5522 100644 --- a/request/graphql/schema/collection.go +++ b/request/graphql/schema/collection.go @@ -323,28 +323,20 @@ func fieldsFromAST(field *ast.FieldDefinition, schema := "" relationName := "" - relationType := client.RelationType(0) + relationType := relationType(0) fieldDescriptions := []client.FieldDescription{} if kind == client.FieldKind_FOREIGN_OBJECT || kind == client.FieldKind_FOREIGN_OBJECT_ARRAY { if kind == client.FieldKind_FOREIGN_OBJECT { schema = field.Type.(*ast.Named).Name.Value - relationType = client.Relation_Type_ONE + relationType = relation_Type_ONE if _, exists := findDirective(field, "primary"); exists { - relationType |= client.Relation_Type_Primary + relationType |= relation_Type_Primary } - - // An _id field is added for every 1-N relationship from this object. - fieldDescriptions = append(fieldDescriptions, client.FieldDescription{ - Name: fmt.Sprintf("%s_id", field.Name.Value), - Kind: client.FieldKind_DocID, - Typ: defaultCRDTForFieldKind[client.FieldKind_DocID], - RelationType: client.Relation_Type_INTERNAL_ID, - }) } else if kind == client.FieldKind_FOREIGN_OBJECT_ARRAY { schema = field.Type.(*ast.List).Type.(*ast.Named).Name.Value - relationType = client.Relation_Type_MANY + relationType = relation_Type_MANY } relationName, err = getRelationshipName(field, hostObjectName, schema) @@ -352,6 +344,16 @@ func fieldsFromAST(field *ast.FieldDefinition, return nil, err } + if kind == client.FieldKind_FOREIGN_OBJECT { + // An _id field is added for every 1-N relationship from this object. + fieldDescriptions = append(fieldDescriptions, client.FieldDescription{ + Name: fmt.Sprintf("%s_id", field.Name.Value), + Kind: client.FieldKind_DocID, + Typ: defaultCRDTForFieldKind[client.FieldKind_DocID], + RelationName: relationName, + }) + } + // Register the relationship so that the relationship manager can evaluate // relationsip properties dependent on both collections in the relationship. _, err := relationManager.RegisterSingle( @@ -376,7 +378,6 @@ func fieldsFromAST(field *ast.FieldDefinition, Typ: cType, Schema: schema, RelationName: relationName, - RelationType: relationType, } fieldDescriptions = append(fieldDescriptions, fieldDescription) @@ -525,7 +526,7 @@ func finalizeRelations(relationManager *RelationManager, definitions []client.Co for _, definition := range definitions { for i, field := range definition.Schema.Fields { - if field.RelationType == 0 || field.RelationType&client.Relation_Type_INTERNAL_ID != 0 { + if field.RelationName == "" || field.Kind == client.FieldKind_DocID { continue } @@ -534,7 +535,7 @@ func finalizeRelations(relationManager *RelationManager, definitions []client.Co return err } - _, fieldRelationType, ok := rel.GetField(field.Schema, field.Name) + _, fieldRelationType, ok := rel.getField(field.Schema, field.Name) if !ok { return NewErrRelationMissingField(field.Schema, field.Name) } @@ -550,7 +551,7 @@ func finalizeRelations(relationManager *RelationManager, definitions []client.Co return client.NewErrRelationOneSided(field.Name, field.Schema) } - field.RelationType = rel.Kind() | fieldRelationType + field.IsPrimaryRelation = fieldRelationType.isSet(relation_Type_Primary) definition.Schema.Fields[i] = field } } diff --git a/request/graphql/schema/descriptions_test.go b/request/graphql/schema/descriptions_test.go index 5a168fcf11..967afea5fe 100644 --- a/request/graphql/schema/descriptions_test.go +++ b/request/graphql/schema/descriptions_test.go @@ -180,13 +180,11 @@ func TestSingleSimpleType(t *testing.T) { Kind: client.FieldKind_FOREIGN_OBJECT, Typ: client.NONE_CRDT, Schema: "Author", - RelationType: client.Relation_Type_ONE | client.Relation_Type_ONEONE, }, { - Name: "author_id", - Kind: client.FieldKind_DocID, - Typ: client.LWW_REGISTER, - RelationType: client.Relation_Type_INTERNAL_ID, + Name: "author_id", + Kind: client.FieldKind_DocID, + Typ: client.LWW_REGISTER, }, { Name: "name", @@ -225,18 +223,17 @@ func TestSingleSimpleType(t *testing.T) { Typ: client.LWW_REGISTER, }, { - Name: "published", - RelationName: "author_book", - Kind: client.FieldKind_FOREIGN_OBJECT, - Typ: client.NONE_CRDT, - Schema: "Book", - RelationType: client.Relation_Type_ONE | client.Relation_Type_ONEONE | client.Relation_Type_Primary, + Name: "published", + RelationName: "author_book", + Kind: client.FieldKind_FOREIGN_OBJECT, + Typ: client.NONE_CRDT, + Schema: "Book", + IsPrimaryRelation: true, }, { - Name: "published_id", - Kind: client.FieldKind_DocID, - Typ: client.LWW_REGISTER, - RelationType: client.Relation_Type_INTERNAL_ID, + Name: "published_id", + Kind: client.FieldKind_DocID, + Typ: client.LWW_REGISTER, }, }, }, @@ -358,13 +355,11 @@ func TestSingleSimpleType(t *testing.T) { Kind: client.FieldKind_FOREIGN_OBJECT, Typ: client.NONE_CRDT, Schema: "Author", - RelationType: client.Relation_Type_ONE | client.Relation_Type_ONEONE, }, { - Name: "author_id", - Kind: client.FieldKind_DocID, - Typ: client.LWW_REGISTER, - RelationType: client.Relation_Type_INTERNAL_ID, + Name: "author_id", + Kind: client.FieldKind_DocID, + Typ: client.LWW_REGISTER, }, { Name: "name", @@ -403,18 +398,17 @@ func TestSingleSimpleType(t *testing.T) { Typ: client.LWW_REGISTER, }, { - Name: "published", - RelationName: "book_authors", - Kind: client.FieldKind_FOREIGN_OBJECT, - Typ: client.NONE_CRDT, - Schema: "Book", - RelationType: client.Relation_Type_ONE | client.Relation_Type_ONEONE | client.Relation_Type_Primary, + Name: "published", + RelationName: "book_authors", + Kind: client.FieldKind_FOREIGN_OBJECT, + Typ: client.NONE_CRDT, + Schema: "Book", + IsPrimaryRelation: true, }, { - Name: "published_id", - Kind: client.FieldKind_DocID, - Typ: client.LWW_REGISTER, - RelationType: client.Relation_Type_INTERNAL_ID, + Name: "published_id", + Kind: client.FieldKind_DocID, + Typ: client.LWW_REGISTER, }, }, }, @@ -451,18 +445,17 @@ func TestSingleSimpleType(t *testing.T) { Typ: client.NONE_CRDT, }, { - Name: "author", - RelationName: "author_book", - Kind: client.FieldKind_FOREIGN_OBJECT, - Typ: client.NONE_CRDT, - Schema: "Author", - RelationType: client.Relation_Type_ONE | client.Relation_Type_ONEONE | client.Relation_Type_Primary, + Name: "author", + RelationName: "author_book", + Kind: client.FieldKind_FOREIGN_OBJECT, + Typ: client.NONE_CRDT, + Schema: "Author", + IsPrimaryRelation: true, }, { - Name: "author_id", - Kind: client.FieldKind_DocID, - Typ: client.LWW_REGISTER, - RelationType: client.Relation_Type_INTERNAL_ID, + Name: "author_id", + Kind: client.FieldKind_DocID, + Typ: client.LWW_REGISTER, }, { Name: "name", @@ -506,13 +499,11 @@ func TestSingleSimpleType(t *testing.T) { Kind: client.FieldKind_FOREIGN_OBJECT, Typ: client.NONE_CRDT, Schema: "Book", - RelationType: client.Relation_Type_ONE | client.Relation_Type_ONEONE, }, { - Name: "published_id", - Kind: client.FieldKind_DocID, - Typ: client.LWW_REGISTER, - RelationType: client.Relation_Type_INTERNAL_ID, + Name: "published_id", + Kind: client.FieldKind_DocID, + Typ: client.LWW_REGISTER, }, }, }, @@ -549,18 +540,17 @@ func TestSingleSimpleType(t *testing.T) { Typ: client.NONE_CRDT, }, { - Name: "author", - RelationName: "author_book", - Kind: client.FieldKind_FOREIGN_OBJECT, - Typ: client.NONE_CRDT, - Schema: "Author", - RelationType: client.Relation_Type_ONE | client.Relation_Type_ONEMANY | client.Relation_Type_Primary, + Name: "author", + RelationName: "author_book", + Kind: client.FieldKind_FOREIGN_OBJECT, + Typ: client.NONE_CRDT, + Schema: "Author", + IsPrimaryRelation: true, }, { - Name: "author_id", - Kind: client.FieldKind_DocID, - Typ: client.LWW_REGISTER, - RelationType: client.Relation_Type_INTERNAL_ID, + Name: "author_id", + Kind: client.FieldKind_DocID, + Typ: client.LWW_REGISTER, }, { Name: "name", @@ -604,7 +594,6 @@ func TestSingleSimpleType(t *testing.T) { Kind: client.FieldKind_FOREIGN_OBJECT_ARRAY, Typ: client.NONE_CRDT, Schema: "Book", - RelationType: client.Relation_Type_MANY | client.Relation_Type_ONEMANY, }, }, }, diff --git a/request/graphql/schema/relations.go b/request/graphql/schema/relations.go index 87d6c7216d..e6d2af8b09 100644 --- a/request/graphql/schema/relations.go +++ b/request/graphql/schema/relations.go @@ -17,6 +17,20 @@ import ( "github.com/sourcenetwork/defradb/client" ) +// relationType describes the type of relation between two types. +type relationType uint8 + +const ( + relation_Type_ONE relationType = 1 // 0b0000 0001 + relation_Type_MANY relationType = 2 // 0b0000 0010 + relation_Type_Primary relationType = 128 // 0b1000 0000 Primary reference entity on relation +) + +// IsSet returns true if the target relation type is set. +func (m relationType) isSet(target relationType) bool { + return m&target > 0 +} + // RelationManager keeps track of all the relations that exist // between schema types type RelationManager struct { @@ -45,29 +59,18 @@ func (rm *RelationManager) RegisterSingle( name string, schemaType string, schemaField string, - relType client.RelationType, + relType relationType, ) (bool, error) { if name == "" { return false, client.NewErrUninitializeProperty("RegisterSingle", "name") } - // make sure the relation type is ONLY One or Many, not both - if relType.IsSet(client.Relation_Type_ONE) == relType.IsSet(client.Relation_Type_MANY) { - return false, ErrRelationMutlipleTypes - } - - // make a copy of rel type, one goes to the relation.relType, and the other goes into the []types. - // We need to clear the Primary bit on the relation.relType so we make a copy - rt := relType - rt &^= client.Relation_Type_Primary // clear the primary bit - rel, ok := rm.relations[name] if !ok { // If a relation doesn't exist then make one. rm.relations[name] = &Relation{ name: name, - relType: rt, - types: []client.RelationType{relType}, + types: []relationType{relType}, schemaTypes: []string{schemaType}, fields: []string{schemaField}, } @@ -76,22 +79,6 @@ func (rm *RelationManager) RegisterSingle( if !rel.finalized { // If a relation exists, and is not finalized, then finalizing it. - - // handle relationType, needs to be either One-to-One, One-to-Many, Many-to-Many. - if rel.relType.IsSet(client.Relation_Type_ONE) { - if relType.IsSet(client.Relation_Type_ONE) { // One-to-One - rel.relType = client.Relation_Type_ONEONE - } else if relType.IsSet(client.Relation_Type_MANY) { - rel.relType = client.Relation_Type_ONEMANY - } - } else { // many - if relType.IsSet(client.Relation_Type_ONE) { - rel.relType = client.Relation_Type_ONEMANY - } else if relType.IsSet(client.Relation_Type_MANY) { - rel.relType = client.Relation_Type_MANYMANY - } - } - rel.types = append(rel.types, relType) rel.schemaTypes = append(rel.schemaTypes, schemaType) rel.fields = append(rel.fields, schemaField) @@ -107,8 +94,7 @@ func (rm *RelationManager) RegisterSingle( type Relation struct { name string - relType client.RelationType - types []client.RelationType + types []relationType schemaTypes []string fields []string @@ -123,57 +109,42 @@ func (r *Relation) finalize() error { return ErrRelationMissingTypes } - // make sure its one of One-to-One, One-to-Many, Many-to-Many - if !r.relType.IsSet(client.Relation_Type_ONEONE) && - !r.relType.IsSet(client.Relation_Type_ONEMANY) && - !r.relType.IsSet(client.Relation_Type_MANYMANY) { - return ErrRelationInvalidType - } - - // make sure we have a primary set if its a one-to-one or many-to-many - if IsOneToOne(r.relType) || IsManyToMany(r.relType) { + if isOne(r.types[0]) && isMany(r.types[1]) { + r.types[0] |= relation_Type_Primary // set primary on one + r.types[1] &^= relation_Type_Primary // clear primary on many + } else if isOne(r.types[1]) && isMany(r.types[0]) { + r.types[1] |= relation_Type_Primary // set primary on one + r.types[0] &^= relation_Type_Primary // clear primary on many + } else if isOne(r.types[1]) && isOne(r.types[0]) { t1, t2 := r.types[0], r.types[1] aBit := t1 & t2 xBit := t1 ^ t2 // both types have primary set - if aBit.IsSet(client.Relation_Type_Primary) { + if aBit.isSet(relation_Type_Primary) { return ErrMultipleRelationPrimaries - } else if !xBit.IsSet(client.Relation_Type_Primary) { + } else if !xBit.isSet(relation_Type_Primary) { // neither type has primary set, auto add to // lexicographically first one by schema type name if strings.Compare(r.schemaTypes[0], r.schemaTypes[1]) < 1 { - r.types[1] = r.types[1] | client.Relation_Type_Primary + r.types[1] = r.types[1] | relation_Type_Primary } else { - r.types[0] = r.types[0] | client.Relation_Type_Primary + r.types[0] = r.types[0] | relation_Type_Primary } } - } else if IsOneToMany(r.relType) { // if its a one-to-many, set the one side as primary - if IsOne(r.types[0]) { - r.types[0] |= client.Relation_Type_Primary // set primary on one - r.types[1] &^= client.Relation_Type_Primary // clear primary on many - } else { - r.types[1] |= client.Relation_Type_Primary // set primary on one - r.types[0] &^= client.Relation_Type_Primary // clear primary on many - } } r.finalized = true return nil } -// Kind returns what type of relation it is -func (r Relation) Kind() client.RelationType { - return r.relType -} - -func (r Relation) GetField(schemaType string, field string) (string, client.RelationType, bool) { +func (r Relation) getField(schemaType string, field string) (string, relationType, bool) { for i, f := range r.fields { if f == field && r.schemaTypes[i] == schemaType { return f, r.types[i], true } } - return "", client.RelationType(0), false + return "", relationType(0), false } func genRelationName(t1, t2 string) (string, error) { @@ -189,55 +160,12 @@ func genRelationName(t1, t2 string) (string, error) { return fmt.Sprintf("%s_%s", t2, t1), nil } -// IsOne returns true if the Relation_ONE bit is set -func IsOne(fieldmeta client.RelationType) bool { - return fieldmeta.IsSet(client.Relation_Type_ONE) -} - -// IsOneToOne returns true if the Relation_ONEONE bit is set -func IsOneToOne(fieldmeta client.RelationType) bool { - return fieldmeta.IsSet(client.Relation_Type_ONEONE) -} - -// IsOneToMany returns true if the Relation_ONEMANY is set -func IsOneToMany(fieldmeta client.RelationType) bool { - return fieldmeta.IsSet(client.Relation_Type_ONEMANY) -} - -// IsManyToMany returns true if the Relation_MANYMANY bit is set -func IsManyToMany(fieldmeta client.RelationType) bool { - return fieldmeta.IsSet(client.Relation_Type_MANYMANY) +// isOne returns true if the Relation_ONE bit is set +func isOne(fieldmeta relationType) bool { + return fieldmeta.isSet(relation_Type_ONE) } -/* Example usage - -rm := NewRelationManager() - -type book { - name: String - rating: Float - author: author -} - -type author { - name: String - age: Int - verified: Boolean - published: [book] +// isMany returns true if the Relation_ONE bit is set +func isMany(fieldmeta relationType) bool { + return fieldmeta.isSet(relation_Type_MANY) } - -Relation names are autogenerated. They are the combination of each type -in the relation, sorted alphabetically. - -Relations: -name: author_book | related types: author, book | fields: author, published - (index same as types) type: one-to-many. - -rm.GetRelations(type) returns all the relations containing that type -rel := rm.GetRelation(name) returns the exact relation (if it exists) between those types -rel.IsPrimary(type) => bool, error -rel.IsOne(type) => bool, error -rel.IsMany(type) => bool, error -rel.Type() OneToOne | OneToMany | ManyToOne? | ManyToMany - -*/ diff --git a/request/graphql/schema/relations_test.go b/request/graphql/schema/relations_test.go deleted file mode 100644 index 50d50baa44..0000000000 --- a/request/graphql/schema/relations_test.go +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2022 Democratized Data Foundation -// -// Use of this software is governed by the Business Source License -// included in the file licenses/BSL.txt. -// -// As of the Change Date specified in that file, in accordance with -// the Business Source License, use of this software will be governed -// by the Apache License, Version 2.0, included in the file -// licenses/APL.txt. - -package schema - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/sourcenetwork/defradb/client" -) - -func TestSimpleOneToOneFromSingle(t *testing.T) { - rm := NewRelationManager() - - /* - type Book { - title: String - author: Author - } - - type Author { - name: String - published: Book - } - - // without explicit @primary directive - // Author is auto set to primary - */ - relName1, err := genRelationName("Book", "Author") - assert.NoError(t, err) - rm.RegisterSingle(relName1, "Author", "author", client.Relation_Type_ONE) - - relName2, err := genRelationName("Author", "Book") - assert.NoError(t, err) - assert.Equal(t, relName1, relName2) - rm.RegisterSingle(relName2, "Book", "published", client.Relation_Type_ONE) - - rel, err := rm.GetRelation(relName1) - assert.NoError(t, err) - assert.Equal(t, rel.relType, client.Relation_Type_ONEONE) -} - -func TestSimpleOneToOnePrimaryFromSingle(t *testing.T) { - rm := NewRelationManager() - - /* - type Book { - title: String - author: Author - } - - type Author { - name: String - published: Book - } - - // without explicit @primary directive - // Author is auto set to primary - */ - relName1, err := genRelationName("Book", "Author") - assert.NoError(t, err) - rm.RegisterSingle(relName1, "Author", "author", client.Relation_Type_ONE) - - relName2, err := genRelationName("Author", "Book") - assert.NoError(t, err) - assert.Equal(t, relName1, relName2) - rm.RegisterSingle( - relName2, - "Book", - "published", - client.Relation_Type_ONE|client.Relation_Type_Primary, - ) - - rel, err := rm.GetRelation(relName1) - assert.NoError(t, err) - assert.Equal(t, rel.relType, client.Relation_Type_ONEONE) -} diff --git a/tests/gen/gen_auto.go b/tests/gen/gen_auto.go index 2573bcda63..80a4303e5e 100644 --- a/tests/gen/gen_auto.go +++ b/tests/gen/gen_auto.go @@ -139,7 +139,7 @@ func (g *randomDocGenerator) generateRandomDocs(order []string) error { continue } if field.IsRelation() { - if field.IsPrimaryRelation() { + if field.IsPrimaryRelation { if strings.HasSuffix(field.Name, request.RelatedObjectID) { newDoc[field.Name] = g.getNextPrimaryDocID(typeName, &field) } else { diff --git a/tests/gen/gen_auto_configurator.go b/tests/gen/gen_auto_configurator.go index 4049e7ba4d..efab79decb 100644 --- a/tests/gen/gen_auto_configurator.go +++ b/tests/gen/gen_auto_configurator.go @@ -339,7 +339,7 @@ func (g *docsGenConfigurator) calculateDemandForSecondaryTypes( ) error { typeDef := g.types[typeName] for _, field := range typeDef.Schema.Fields { - if field.IsObject() && !field.IsPrimaryRelation() { + if field.IsObject() && !field.IsPrimaryRelation { primaryDocDemand := g.docsDemand[typeName] newSecDemand := typeDemand{min: primaryDocDemand.min, max: primaryDocDemand.max} minPerDoc, maxPerDoc := 1, 1 @@ -419,7 +419,7 @@ func getRelationGraph(types map[string]client.CollectionDefinition) map[string][ for typeName, typeDef := range types { for _, field := range typeDef.Schema.Fields { if field.IsObject() { - if field.IsPrimaryRelation() { + if field.IsPrimaryRelation { primaryGraph[typeName] = appendUnique(primaryGraph[typeName], field.Schema) } else { primaryGraph[field.Schema] = appendUnique(primaryGraph[field.Schema], typeName) diff --git a/tests/gen/gen_auto_test.go b/tests/gen/gen_auto_test.go index a43d478c9f..ef4d5d1681 100644 --- a/tests/gen/gen_auto_test.go +++ b/tests/gen/gen_auto_test.go @@ -1212,10 +1212,9 @@ func TestAutoGenerate_IfCollectionDefinitionIsIncomplete_ReturnError(t *testing. Kind: client.FieldKind_NILLABLE_INT, }, { - Name: "device", - Kind: client.FieldKind_FOREIGN_OBJECT, - Schema: "Device", - RelationType: client.Relation_Type_ONE | client.Relation_Type_ONEONE, + Name: "device", + Kind: client.FieldKind_FOREIGN_OBJECT, + Schema: "Device", }, }, }, @@ -1233,12 +1232,10 @@ func TestAutoGenerate_IfCollectionDefinitionIsIncomplete_ReturnError(t *testing. Kind: client.FieldKind_NILLABLE_STRING, }, { - Name: "owner", - Kind: client.FieldKind_FOREIGN_OBJECT, - Schema: "User", - RelationType: client.Relation_Type_ONE | - client.Relation_Type_ONEONE | - client.Relation_Type_Primary, + Name: "owner", + Kind: client.FieldKind_FOREIGN_OBJECT, + Schema: "User", + IsPrimaryRelation: true, }, }, }, @@ -1341,7 +1338,7 @@ func TestAutoGenerate_IfColDefinitionsAreValid_ShouldGenerate(t *testing.T) { Name: "devices", Kind: client.FieldKind_FOREIGN_OBJECT_ARRAY, Schema: "Device", - RelationType: client.Relation_Type_MANY | client.Relation_Type_ONEMANY, + RelationName: "Device_owner", }, }, }, @@ -1361,7 +1358,8 @@ func TestAutoGenerate_IfColDefinitionsAreValid_ShouldGenerate(t *testing.T) { { Name: "owner_id", Kind: client.FieldKind_DocID, - RelationType: client.Relation_Type_INTERNAL_ID, + RelationName: "Device_owner", + Schema: "User", }, }, }, diff --git a/tests/integration/events/simple/with_update_test.go b/tests/integration/events/simple/with_update_test.go index c929bf4384..988b834622 100644 --- a/tests/integration/events/simple/with_update_test.go +++ b/tests/integration/events/simple/with_update_test.go @@ -66,14 +66,14 @@ func TestEventsSimpleWithUpdate(t *testing.T) { ExpectedUpdates: []testUtils.ExpectedUpdate{ { DocID: immutable.Some(docID1), - Cid: immutable.Some("bafybeif5l2a5f2lcsmuml2cji6unq4qk2ta4f3uow4wccdjebsu7jcjrj4"), + Cid: immutable.Some("bafybeiffwlvaz742mg2ejv7v2qd62couktzrejfkzzedzw3djmxpvt5lvi"), }, { DocID: immutable.Some(docID2), }, { DocID: immutable.Some(docID1), - Cid: immutable.Some("bafybeihchzitl7e7pyhci5bs563dn3seykcleqk56r7vjtslvi3rv3wsne"), + Cid: immutable.Some("bafybeidzdbok2dutsjobk62jxgoqttk2omwazvh4ycvrz27ffg7dp4joo4"), }, }, } diff --git a/tests/integration/mutation/create/with_version_test.go b/tests/integration/mutation/create/with_version_test.go index b4578786c9..f4268de4db 100644 --- a/tests/integration/mutation/create/with_version_test.go +++ b/tests/integration/mutation/create/with_version_test.go @@ -39,7 +39,7 @@ func TestMutationCreate_ReturnsVersionCID(t *testing.T) { { "_version": []map[string]any{ { - "cid": "bafybeif5l2a5f2lcsmuml2cji6unq4qk2ta4f3uow4wccdjebsu7jcjrj4", + "cid": "bafybeiffwlvaz742mg2ejv7v2qd62couktzrejfkzzedzw3djmxpvt5lvi", }, }, }, diff --git a/tests/integration/net/state/simple/replicator/with_create_test.go b/tests/integration/net/state/simple/replicator/with_create_test.go index 08433629c4..f30c76ae71 100644 --- a/tests/integration/net/state/simple/replicator/with_create_test.go +++ b/tests/integration/net/state/simple/replicator/with_create_test.go @@ -492,7 +492,7 @@ func TestP2POneToOneReplicatorOrderIndependent(t *testing.T) { "name": "John", "_version": []map[string]any{ { - "schemaVersionId": "bafkreicnoqat3exmvikr36xu3hhrkvay3d3cif24tezgsyvrydpobk2nqm", + "schemaVersionId": "bafkreihh4zkyuqk4ibwb5utyayvbw75hdfkueg3scm7taysk3rbh2jhaee", }, }, }, @@ -552,7 +552,7 @@ func TestP2POneToOneReplicatorOrderIndependentDirectCreate(t *testing.T) { "_docID": "bae-f54b9689-e06e-5e3a-89b3-f3aee8e64ca7", "_version": []map[string]any{ { - "schemaVersionId": "bafkreicnoqat3exmvikr36xu3hhrkvay3d3cif24tezgsyvrydpobk2nqm", + "schemaVersionId": "bafkreihh4zkyuqk4ibwb5utyayvbw75hdfkueg3scm7taysk3rbh2jhaee", }, }, }, diff --git a/tests/integration/query/commits/simple_test.go b/tests/integration/query/commits/simple_test.go index 9592c46d1f..a3d0a01b33 100644 --- a/tests/integration/query/commits/simple_test.go +++ b/tests/integration/query/commits/simple_test.go @@ -36,13 +36,13 @@ func TestQueryCommits(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", }, { - "cid": "bafybeigmez6gtszsqx6aevzlanvpazhhezw5va4wizhqtqz5k4s2dqjb24", + "cid": "bafybeiehcr3diremeja2ndk2osux647v5fc7s353h7pbvrnsagw4paugku", }, { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", }, }, }, @@ -79,22 +79,22 @@ func TestQueryCommitsMultipleDocs(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeigdcaas33fnrv7jbigm5a5phxtxl76weuf74kqcrb5udjgttqssju", + "cid": "bafybeifxmoq5yeukxrizqgncteztxao53d26ch6gqlyciakbrvlxwyob6a", }, { - "cid": "bafybeiahfq2ji7uneqfqddeqsvz5t3rdkgo7wpnpswo2jon23kxpgvqdsa", + "cid": "bafybeigkpb7jwgrsq3dq2nt2cnsarp3nq2ilefsuyz7jwcxfecot3qxwia", }, { - "cid": "bafybeihhadjgfxsyrlg5gftmi4ikppuhecyeqznjru47l3tup4c6sbzhga", + "cid": "bafybeidacwdvdzz7y5r6lqsjgs3kom2zjnlarw6r3rgxlj3iw4kck4mer4", }, { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", }, { - "cid": "bafybeigmez6gtszsqx6aevzlanvpazhhezw5va4wizhqtqz5k4s2dqjb24", + "cid": "bafybeiehcr3diremeja2ndk2osux647v5fc7s353h7pbvrnsagw4paugku", }, { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", }, }, }, @@ -125,16 +125,16 @@ func TestQueryCommitsWithSchemaVersionIdField(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", - "schemaVersionId": "bafkreiayhdsgzhmrz6t5d3x2cgqqbdjt7aqgldtlkmxn5eibg542j3n6ea", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", + "schemaVersionId": "bafkreidjvyxputjthx4wzyxtk33fce3shqguif3yhifykilybpn6canony", }, { - "cid": "bafybeigmez6gtszsqx6aevzlanvpazhhezw5va4wizhqtqz5k4s2dqjb24", - "schemaVersionId": "bafkreiayhdsgzhmrz6t5d3x2cgqqbdjt7aqgldtlkmxn5eibg542j3n6ea", + "cid": "bafybeiehcr3diremeja2ndk2osux647v5fc7s353h7pbvrnsagw4paugku", + "schemaVersionId": "bafkreidjvyxputjthx4wzyxtk33fce3shqguif3yhifykilybpn6canony", }, { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", - "schemaVersionId": "bafkreiayhdsgzhmrz6t5d3x2cgqqbdjt7aqgldtlkmxn5eibg542j3n6ea", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", + "schemaVersionId": "bafkreidjvyxputjthx4wzyxtk33fce3shqguif3yhifykilybpn6canony", }, }, }, diff --git a/tests/integration/query/commits/with_cid_test.go b/tests/integration/query/commits/with_cid_test.go index 5c2703d41c..7782d7c514 100644 --- a/tests/integration/query/commits/with_cid_test.go +++ b/tests/integration/query/commits/with_cid_test.go @@ -38,14 +38,14 @@ func TestQueryCommitsWithCid(t *testing.T) { testUtils.Request{ Request: `query { commits( - cid: "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u" + cid: "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu" ) { cid } }`, Results: []map[string]any{ { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", }, }, }, @@ -71,14 +71,14 @@ func TestQueryCommitsWithCidForFieldCommit(t *testing.T) { testUtils.Request{ Request: `query { commits( - cid: "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u" + cid: "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu" ) { cid } }`, Results: []map[string]any{ { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", }, }, }, diff --git a/tests/integration/query/commits/with_depth_test.go b/tests/integration/query/commits/with_depth_test.go index a0d2c817f4..18215fd6f9 100644 --- a/tests/integration/query/commits/with_depth_test.go +++ b/tests/integration/query/commits/with_depth_test.go @@ -36,13 +36,13 @@ func TestQueryCommitsWithDepth1(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", }, { - "cid": "bafybeigmez6gtszsqx6aevzlanvpazhhezw5va4wizhqtqz5k4s2dqjb24", + "cid": "bafybeiehcr3diremeja2ndk2osux647v5fc7s353h7pbvrnsagw4paugku", }, { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", }, }, }, @@ -81,16 +81,16 @@ func TestQueryCommitsWithDepth1WithUpdate(t *testing.T) { Results: []map[string]any{ { // "Age" field head - "cid": "bafybeihqgrwnhc4w7e5cbhycxvqrpzgi2ei4xrcsre2plceclptgn4tc3i", + "cid": "bafybeiddpjl27ulw2yo4ohup6gr2wob3pwagqw2rbeaxxodv4ljelnu7ve", "height": int64(2), }, { // "Name" field head (unchanged from create) - "cid": "bafybeigmez6gtszsqx6aevzlanvpazhhezw5va4wizhqtqz5k4s2dqjb24", + "cid": "bafybeiehcr3diremeja2ndk2osux647v5fc7s353h7pbvrnsagw4paugku", "height": int64(1), }, { - "cid": "bafybeibfwqf5szatmlyl3alru4nq3gnxaiyyb3ggqung2jwb4qnm6mejyu", + "cid": "bafybeiekajrgheumrgamrc4mprmm66ulp2qr75sviowfcriuviggokydbm", "height": int64(2), }, }, @@ -137,27 +137,27 @@ func TestQueryCommitsWithDepth2WithUpdate(t *testing.T) { Results: []map[string]any{ { // Composite head - "cid": "bafybeihvhr7ke7bjgjixce262544tlo7mdlyuswtgl66zsrxcfc5targjy", + "cid": "bafybeibfip3j6fr755tjjhlmuqxqywlmgxbalgbnhggq3xj3xvtwe6f6jy", "height": int64(3), }, { // Composite head -1 - "cid": "bafybeihqgrwnhc4w7e5cbhycxvqrpzgi2ei4xrcsre2plceclptgn4tc3i", + "cid": "bafybeiddpjl27ulw2yo4ohup6gr2wob3pwagqw2rbeaxxodv4ljelnu7ve", "height": int64(2), }, { // "Name" field head (unchanged from create) - "cid": "bafybeigmez6gtszsqx6aevzlanvpazhhezw5va4wizhqtqz5k4s2dqjb24", + "cid": "bafybeiehcr3diremeja2ndk2osux647v5fc7s353h7pbvrnsagw4paugku", "height": int64(1), }, { // "Age" field head - "cid": "bafybeicacrvck5qf37pk3pdsiavvxy2jk67dbdpww5pvoun2k52lw2ftqi", + "cid": "bafybeigomkxadtuj4vfkb7ix55d2qhnzh24wnxv4gqvbo2s5hdtyf2y7im", "height": int64(3), }, { // "Age" field head -1 - "cid": "bafybeibfwqf5szatmlyl3alru4nq3gnxaiyyb3ggqung2jwb4qnm6mejyu", + "cid": "bafybeiekajrgheumrgamrc4mprmm66ulp2qr75sviowfcriuviggokydbm", "height": int64(2), }, }, @@ -195,22 +195,22 @@ func TestQueryCommitsWithDepth1AndMultipleDocs(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeigvcksw7ck2o7rqfyxncn2h5u6bbwj5ejjfvsihsjibxvrqrxbtui", + "cid": "bafybeihf2bo3amfoojd3ihliafgtka4jxava5i6rmujktvzon2x4iuzzna", }, { - "cid": "bafybeibcdmghhshx4v3xamoktw3n6blv7courh6x2d5cttwuzlodml74ny", + "cid": "bafybeic4lebzixuxdsgzqs4nvy6ont7sheognehdbmpr27ha2cvror6v4m", }, { - "cid": "bafybeig6rwkq6hlf5rcjq64jodl3gtfv5svnmsjlkwrnmbcjui7t3vy3qi", + "cid": "bafybeietgsruk6dlepqsre27fripbsjnwawpmygnwdxsmpt5vb6q4mkdxi", }, { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", }, { - "cid": "bafybeigmez6gtszsqx6aevzlanvpazhhezw5va4wizhqtqz5k4s2dqjb24", + "cid": "bafybeiehcr3diremeja2ndk2osux647v5fc7s353h7pbvrnsagw4paugku", }, { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", }, }, }, diff --git a/tests/integration/query/commits/with_doc_id_cid_test.go b/tests/integration/query/commits/with_doc_id_cid_test.go index 48878ae06c..549cbe0ff5 100644 --- a/tests/integration/query/commits/with_doc_id_cid_test.go +++ b/tests/integration/query/commits/with_doc_id_cid_test.go @@ -104,14 +104,14 @@ func TestQueryCommitsWithDocIDAndCidWithUpdate(t *testing.T) { Request: ` { commits( docID: "bae-f54b9689-e06e-5e3a-89b3-f3aee8e64ca7", - cid: "bafybeibfwqf5szatmlyl3alru4nq3gnxaiyyb3ggqung2jwb4qnm6mejyu" + cid: "bafybeiekajrgheumrgamrc4mprmm66ulp2qr75sviowfcriuviggokydbm" ) { cid } }`, Results: []map[string]any{ { - "cid": "bafybeibfwqf5szatmlyl3alru4nq3gnxaiyyb3ggqung2jwb4qnm6mejyu", + "cid": "bafybeiekajrgheumrgamrc4mprmm66ulp2qr75sviowfcriuviggokydbm", }, }, }, diff --git a/tests/integration/query/commits/with_doc_id_count_test.go b/tests/integration/query/commits/with_doc_id_count_test.go index abab180695..cf2a4d57c8 100644 --- a/tests/integration/query/commits/with_doc_id_count_test.go +++ b/tests/integration/query/commits/with_doc_id_count_test.go @@ -37,15 +37,15 @@ func TestQueryCommitsWithDocIDAndLinkCount(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", "_count": 0, }, { - "cid": "bafybeigmez6gtszsqx6aevzlanvpazhhezw5va4wizhqtqz5k4s2dqjb24", + "cid": "bafybeiehcr3diremeja2ndk2osux647v5fc7s353h7pbvrnsagw4paugku", "_count": 0, }, { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", "_count": 2, }, }, diff --git a/tests/integration/query/commits/with_doc_id_field_test.go b/tests/integration/query/commits/with_doc_id_field_test.go index 3de42d2e42..dc80f1cbc8 100644 --- a/tests/integration/query/commits/with_doc_id_field_test.go +++ b/tests/integration/query/commits/with_doc_id_field_test.go @@ -118,7 +118,7 @@ func TestQueryCommitsWithDocIDAndFieldId(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", }, }, }, @@ -150,7 +150,7 @@ func TestQueryCommitsWithDocIDAndCompositeFieldId(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", }, }, }, diff --git a/tests/integration/query/commits/with_doc_id_limit_offset_test.go b/tests/integration/query/commits/with_doc_id_limit_offset_test.go index e56dfb6d85..2b2de9ac4c 100644 --- a/tests/integration/query/commits/with_doc_id_limit_offset_test.go +++ b/tests/integration/query/commits/with_doc_id_limit_offset_test.go @@ -57,10 +57,10 @@ func TestQueryCommitsWithDocIDAndLimitAndOffset(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeihvhr7ke7bjgjixce262544tlo7mdlyuswtgl66zsrxcfc5targjy", + "cid": "bafybeibfip3j6fr755tjjhlmuqxqywlmgxbalgbnhggq3xj3xvtwe6f6jy", }, { - "cid": "bafybeihqgrwnhc4w7e5cbhycxvqrpzgi2ei4xrcsre2plceclptgn4tc3i", + "cid": "bafybeiddpjl27ulw2yo4ohup6gr2wob3pwagqw2rbeaxxodv4ljelnu7ve", }, }, }, diff --git a/tests/integration/query/commits/with_doc_id_limit_test.go b/tests/integration/query/commits/with_doc_id_limit_test.go index 7c4a4b2fc8..9edd44831e 100644 --- a/tests/integration/query/commits/with_doc_id_limit_test.go +++ b/tests/integration/query/commits/with_doc_id_limit_test.go @@ -50,10 +50,10 @@ func TestQueryCommitsWithDocIDAndLimit(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeihvhr7ke7bjgjixce262544tlo7mdlyuswtgl66zsrxcfc5targjy", + "cid": "bafybeibfip3j6fr755tjjhlmuqxqywlmgxbalgbnhggq3xj3xvtwe6f6jy", }, { - "cid": "bafybeihqgrwnhc4w7e5cbhycxvqrpzgi2ei4xrcsre2plceclptgn4tc3i", + "cid": "bafybeiddpjl27ulw2yo4ohup6gr2wob3pwagqw2rbeaxxodv4ljelnu7ve", }, }, }, diff --git a/tests/integration/query/commits/with_doc_id_order_limit_offset_test.go b/tests/integration/query/commits/with_doc_id_order_limit_offset_test.go index 9312c66928..ee52a154c3 100644 --- a/tests/integration/query/commits/with_doc_id_order_limit_offset_test.go +++ b/tests/integration/query/commits/with_doc_id_order_limit_offset_test.go @@ -58,11 +58,11 @@ func TestQueryCommitsWithDocIDAndOrderAndLimitAndOffset(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeibfwqf5szatmlyl3alru4nq3gnxaiyyb3ggqung2jwb4qnm6mejyu", + "cid": "bafybeiekajrgheumrgamrc4mprmm66ulp2qr75sviowfcriuviggokydbm", "height": int64(2), }, { - "cid": "bafybeihvhr7ke7bjgjixce262544tlo7mdlyuswtgl66zsrxcfc5targjy", + "cid": "bafybeibfip3j6fr755tjjhlmuqxqywlmgxbalgbnhggq3xj3xvtwe6f6jy", "height": int64(3), }, }, diff --git a/tests/integration/query/commits/with_doc_id_order_test.go b/tests/integration/query/commits/with_doc_id_order_test.go index f89121e199..368b062874 100644 --- a/tests/integration/query/commits/with_doc_id_order_test.go +++ b/tests/integration/query/commits/with_doc_id_order_test.go @@ -44,23 +44,23 @@ func TestQueryCommitsWithDocIDAndOrderHeightDesc(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeihqgrwnhc4w7e5cbhycxvqrpzgi2ei4xrcsre2plceclptgn4tc3i", + "cid": "bafybeiddpjl27ulw2yo4ohup6gr2wob3pwagqw2rbeaxxodv4ljelnu7ve", "height": int64(2), }, { - "cid": "bafybeibfwqf5szatmlyl3alru4nq3gnxaiyyb3ggqung2jwb4qnm6mejyu", + "cid": "bafybeiekajrgheumrgamrc4mprmm66ulp2qr75sviowfcriuviggokydbm", "height": int64(2), }, { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", "height": int64(1), }, { - "cid": "bafybeigmez6gtszsqx6aevzlanvpazhhezw5va4wizhqtqz5k4s2dqjb24", + "cid": "bafybeiehcr3diremeja2ndk2osux647v5fc7s353h7pbvrnsagw4paugku", "height": int64(1), }, { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", "height": int64(1), }, }, @@ -99,23 +99,23 @@ func TestQueryCommitsWithDocIDAndOrderHeightAsc(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", "height": int64(1), }, { - "cid": "bafybeigmez6gtszsqx6aevzlanvpazhhezw5va4wizhqtqz5k4s2dqjb24", + "cid": "bafybeiehcr3diremeja2ndk2osux647v5fc7s353h7pbvrnsagw4paugku", "height": int64(1), }, { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", "height": int64(1), }, { - "cid": "bafybeihqgrwnhc4w7e5cbhycxvqrpzgi2ei4xrcsre2plceclptgn4tc3i", + "cid": "bafybeiddpjl27ulw2yo4ohup6gr2wob3pwagqw2rbeaxxodv4ljelnu7ve", "height": int64(2), }, { - "cid": "bafybeibfwqf5szatmlyl3alru4nq3gnxaiyyb3ggqung2jwb4qnm6mejyu", + "cid": "bafybeiekajrgheumrgamrc4mprmm66ulp2qr75sviowfcriuviggokydbm", "height": int64(2), }, }, @@ -154,23 +154,23 @@ func TestQueryCommitsWithDocIDAndOrderCidDesc(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeihqgrwnhc4w7e5cbhycxvqrpzgi2ei4xrcsre2plceclptgn4tc3i", - "height": int64(2), + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", + "height": int64(1), }, { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", - "height": int64(1), + "cid": "bafybeiekajrgheumrgamrc4mprmm66ulp2qr75sviowfcriuviggokydbm", + "height": int64(2), }, { - "cid": "bafybeigmez6gtszsqx6aevzlanvpazhhezw5va4wizhqtqz5k4s2dqjb24", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", "height": int64(1), }, { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", + "cid": "bafybeiehcr3diremeja2ndk2osux647v5fc7s353h7pbvrnsagw4paugku", "height": int64(1), }, { - "cid": "bafybeibfwqf5szatmlyl3alru4nq3gnxaiyyb3ggqung2jwb4qnm6mejyu", + "cid": "bafybeiddpjl27ulw2yo4ohup6gr2wob3pwagqw2rbeaxxodv4ljelnu7ve", "height": int64(2), }, }, @@ -209,24 +209,24 @@ func TestQueryCommitsWithDocIDAndOrderCidAsc(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeibfwqf5szatmlyl3alru4nq3gnxaiyyb3ggqung2jwb4qnm6mejyu", + "cid": "bafybeiddpjl27ulw2yo4ohup6gr2wob3pwagqw2rbeaxxodv4ljelnu7ve", "height": int64(2), }, { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", + "cid": "bafybeiehcr3diremeja2ndk2osux647v5fc7s353h7pbvrnsagw4paugku", "height": int64(1), }, { - "cid": "bafybeigmez6gtszsqx6aevzlanvpazhhezw5va4wizhqtqz5k4s2dqjb24", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", "height": int64(1), }, { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", - "height": int64(1), + "cid": "bafybeiekajrgheumrgamrc4mprmm66ulp2qr75sviowfcriuviggokydbm", + "height": int64(2), }, { - "cid": "bafybeihqgrwnhc4w7e5cbhycxvqrpzgi2ei4xrcsre2plceclptgn4tc3i", - "height": int64(2), + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", + "height": int64(1), }, }, }, @@ -278,39 +278,39 @@ func TestQueryCommitsWithDocIDAndOrderAndMultiUpdatesCidAsc(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", "height": int64(1), }, { - "cid": "bafybeigmez6gtszsqx6aevzlanvpazhhezw5va4wizhqtqz5k4s2dqjb24", + "cid": "bafybeiehcr3diremeja2ndk2osux647v5fc7s353h7pbvrnsagw4paugku", "height": int64(1), }, { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", "height": int64(1), }, { - "cid": "bafybeihqgrwnhc4w7e5cbhycxvqrpzgi2ei4xrcsre2plceclptgn4tc3i", + "cid": "bafybeiddpjl27ulw2yo4ohup6gr2wob3pwagqw2rbeaxxodv4ljelnu7ve", "height": int64(2), }, { - "cid": "bafybeibfwqf5szatmlyl3alru4nq3gnxaiyyb3ggqung2jwb4qnm6mejyu", + "cid": "bafybeiekajrgheumrgamrc4mprmm66ulp2qr75sviowfcriuviggokydbm", "height": int64(2), }, { - "cid": "bafybeihvhr7ke7bjgjixce262544tlo7mdlyuswtgl66zsrxcfc5targjy", + "cid": "bafybeibfip3j6fr755tjjhlmuqxqywlmgxbalgbnhggq3xj3xvtwe6f6jy", "height": int64(3), }, { - "cid": "bafybeicacrvck5qf37pk3pdsiavvxy2jk67dbdpww5pvoun2k52lw2ftqi", + "cid": "bafybeigomkxadtuj4vfkb7ix55d2qhnzh24wnxv4gqvbo2s5hdtyf2y7im", "height": int64(3), }, { - "cid": "bafybeicv72yzbkdmp5r32eesxcna7rqyuhwoovg66kkivclzji3onbwm3a", + "cid": "bafybeigrdrat2xyrfzryclfequ5isakqorz6oedvq2vl6cjektcpmmt7fm", "height": int64(4), }, { - "cid": "bafybeicf36fznyghq3spknjabxrp72kf66khrzscco3rnyat3ezaufhon4", + "cid": "bafybeibvbwkak42qyfgwg6rnlfelhovriqucsuq2kz77d6z7h7m46k4sdi", "height": int64(4), }, }, diff --git a/tests/integration/query/commits/with_doc_id_test.go b/tests/integration/query/commits/with_doc_id_test.go index c754a18fde..5d6575d3c0 100644 --- a/tests/integration/query/commits/with_doc_id_test.go +++ b/tests/integration/query/commits/with_doc_id_test.go @@ -62,13 +62,13 @@ func TestQueryCommitsWithDocID(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", }, { - "cid": "bafybeigmez6gtszsqx6aevzlanvpazhhezw5va4wizhqtqz5k4s2dqjb24", + "cid": "bafybeiehcr3diremeja2ndk2osux647v5fc7s353h7pbvrnsagw4paugku", }, { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", }, }, }, @@ -102,22 +102,22 @@ func TestQueryCommitsWithDocIDAndLinks(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", "links": []map[string]any{}, }, { - "cid": "bafybeigmez6gtszsqx6aevzlanvpazhhezw5va4wizhqtqz5k4s2dqjb24", + "cid": "bafybeiehcr3diremeja2ndk2osux647v5fc7s353h7pbvrnsagw4paugku", "links": []map[string]any{}, }, { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", "links": []map[string]any{ { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", "name": "age", }, { - "cid": "bafybeigmez6gtszsqx6aevzlanvpazhhezw5va4wizhqtqz5k4s2dqjb24", + "cid": "bafybeiehcr3diremeja2ndk2osux647v5fc7s353h7pbvrnsagw4paugku", "name": "name", }, }, @@ -158,23 +158,23 @@ func TestQueryCommitsWithDocIDAndUpdate(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeihqgrwnhc4w7e5cbhycxvqrpzgi2ei4xrcsre2plceclptgn4tc3i", + "cid": "bafybeiddpjl27ulw2yo4ohup6gr2wob3pwagqw2rbeaxxodv4ljelnu7ve", "height": int64(2), }, { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", "height": int64(1), }, { - "cid": "bafybeigmez6gtszsqx6aevzlanvpazhhezw5va4wizhqtqz5k4s2dqjb24", + "cid": "bafybeiehcr3diremeja2ndk2osux647v5fc7s353h7pbvrnsagw4paugku", "height": int64(1), }, { - "cid": "bafybeibfwqf5szatmlyl3alru4nq3gnxaiyyb3ggqung2jwb4qnm6mejyu", + "cid": "bafybeiekajrgheumrgamrc4mprmm66ulp2qr75sviowfcriuviggokydbm", "height": int64(2), }, { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", "height": int64(1), }, }, @@ -219,44 +219,44 @@ func TestQueryCommitsWithDocIDAndUpdateAndLinks(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeihqgrwnhc4w7e5cbhycxvqrpzgi2ei4xrcsre2plceclptgn4tc3i", + "cid": "bafybeiddpjl27ulw2yo4ohup6gr2wob3pwagqw2rbeaxxodv4ljelnu7ve", "links": []map[string]any{ { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", "name": "_head", }, }, }, { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", "links": []map[string]any{}, }, { - "cid": "bafybeigmez6gtszsqx6aevzlanvpazhhezw5va4wizhqtqz5k4s2dqjb24", + "cid": "bafybeiehcr3diremeja2ndk2osux647v5fc7s353h7pbvrnsagw4paugku", "links": []map[string]any{}, }, { - "cid": "bafybeibfwqf5szatmlyl3alru4nq3gnxaiyyb3ggqung2jwb4qnm6mejyu", + "cid": "bafybeiekajrgheumrgamrc4mprmm66ulp2qr75sviowfcriuviggokydbm", "links": []map[string]any{ { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", "name": "_head", }, { - "cid": "bafybeihqgrwnhc4w7e5cbhycxvqrpzgi2ei4xrcsre2plceclptgn4tc3i", + "cid": "bafybeiddpjl27ulw2yo4ohup6gr2wob3pwagqw2rbeaxxodv4ljelnu7ve", "name": "age", }, }, }, { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", "links": []map[string]any{ { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", "name": "age", }, { - "cid": "bafybeigmez6gtszsqx6aevzlanvpazhhezw5va4wizhqtqz5k4s2dqjb24", + "cid": "bafybeiehcr3diremeja2ndk2osux647v5fc7s353h7pbvrnsagw4paugku", "name": "name", }, }, diff --git a/tests/integration/query/commits/with_doc_id_typename_test.go b/tests/integration/query/commits/with_doc_id_typename_test.go index 8248724cd8..c2daacea47 100644 --- a/tests/integration/query/commits/with_doc_id_typename_test.go +++ b/tests/integration/query/commits/with_doc_id_typename_test.go @@ -37,15 +37,15 @@ func TestQueryCommitsWithDocIDWithTypeName(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", "__typename": "Commit", }, { - "cid": "bafybeigmez6gtszsqx6aevzlanvpazhhezw5va4wizhqtqz5k4s2dqjb24", + "cid": "bafybeiehcr3diremeja2ndk2osux647v5fc7s353h7pbvrnsagw4paugku", "__typename": "Commit", }, { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", "__typename": "Commit", }, }, diff --git a/tests/integration/query/commits/with_field_test.go b/tests/integration/query/commits/with_field_test.go index 45b0acf550..72f2824150 100644 --- a/tests/integration/query/commits/with_field_test.go +++ b/tests/integration/query/commits/with_field_test.go @@ -66,7 +66,7 @@ func TestQueryCommitsWithFieldId(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", }, }, }, @@ -98,7 +98,7 @@ func TestQueryCommitsWithCompositeFieldId(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", }, }, }, @@ -131,8 +131,8 @@ func TestQueryCommitsWithCompositeFieldIdWithReturnedSchemaVersionId(t *testing. }`, Results: []map[string]any{ { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", - "schemaVersionId": "bafkreiayhdsgzhmrz6t5d3x2cgqqbdjt7aqgldtlkmxn5eibg542j3n6ea", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", + "schemaVersionId": "bafkreidjvyxputjthx4wzyxtk33fce3shqguif3yhifykilybpn6canony", }, }, }, diff --git a/tests/integration/query/commits/with_group_test.go b/tests/integration/query/commits/with_group_test.go index d7c539a999..1f77f71ec7 100644 --- a/tests/integration/query/commits/with_group_test.go +++ b/tests/integration/query/commits/with_group_test.go @@ -89,10 +89,10 @@ func TestQueryCommitsWithGroupByHeightWithChild(t *testing.T) { "height": int64(2), "_group": []map[string]any{ { - "cid": "bafybeihqgrwnhc4w7e5cbhycxvqrpzgi2ei4xrcsre2plceclptgn4tc3i", + "cid": "bafybeiddpjl27ulw2yo4ohup6gr2wob3pwagqw2rbeaxxodv4ljelnu7ve", }, { - "cid": "bafybeibfwqf5szatmlyl3alru4nq3gnxaiyyb3ggqung2jwb4qnm6mejyu", + "cid": "bafybeiekajrgheumrgamrc4mprmm66ulp2qr75sviowfcriuviggokydbm", }, }, }, @@ -100,13 +100,13 @@ func TestQueryCommitsWithGroupByHeightWithChild(t *testing.T) { "height": int64(1), "_group": []map[string]any{ { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", }, { - "cid": "bafybeigmez6gtszsqx6aevzlanvpazhhezw5va4wizhqtqz5k4s2dqjb24", + "cid": "bafybeiehcr3diremeja2ndk2osux647v5fc7s353h7pbvrnsagw4paugku", }, { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", }, }, }, @@ -142,7 +142,7 @@ func TestQueryCommitsWithGroupByCidWithChild(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", "_group": []map[string]any{ { "height": int64(1), @@ -150,7 +150,7 @@ func TestQueryCommitsWithGroupByCidWithChild(t *testing.T) { }, }, { - "cid": "bafybeigmez6gtszsqx6aevzlanvpazhhezw5va4wizhqtqz5k4s2dqjb24", + "cid": "bafybeiehcr3diremeja2ndk2osux647v5fc7s353h7pbvrnsagw4paugku", "_group": []map[string]any{ { "height": int64(1), @@ -158,7 +158,7 @@ func TestQueryCommitsWithGroupByCidWithChild(t *testing.T) { }, }, { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", "_group": []map[string]any{ { "height": int64(1), diff --git a/tests/integration/query/latest_commits/with_doc_id_field_test.go b/tests/integration/query/latest_commits/with_doc_id_field_test.go index 9f3441e52e..7e366b48bf 100644 --- a/tests/integration/query/latest_commits/with_doc_id_field_test.go +++ b/tests/integration/query/latest_commits/with_doc_id_field_test.go @@ -68,7 +68,7 @@ func TestQueryLatestCommitsWithDocIDAndFieldId(t *testing.T) { }, Results: []map[string]any{ { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", "links": []map[string]any{}, }, }, @@ -101,14 +101,14 @@ func TestQueryLatestCommitsWithDocIDAndCompositeFieldId(t *testing.T) { }, Results: []map[string]any{ { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", "links": []map[string]any{ { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", "name": "age", }, { - "cid": "bafybeigmez6gtszsqx6aevzlanvpazhhezw5va4wizhqtqz5k4s2dqjb24", + "cid": "bafybeiehcr3diremeja2ndk2osux647v5fc7s353h7pbvrnsagw4paugku", "name": "name", }, }, diff --git a/tests/integration/query/latest_commits/with_doc_id_test.go b/tests/integration/query/latest_commits/with_doc_id_test.go index 4d02a8d96e..edeef2072f 100644 --- a/tests/integration/query/latest_commits/with_doc_id_test.go +++ b/tests/integration/query/latest_commits/with_doc_id_test.go @@ -38,14 +38,14 @@ func TestQueryLatestCommitsWithDocID(t *testing.T) { }, Results: []map[string]any{ { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", "links": []map[string]any{ { - "cid": "bafybeihfw5lufgs7ygv45to5rqvt3xkecjgikoccjyx6y2i7lnaclmrcjm", + "cid": "bafybeieikx6l2xead2dzsa5wwy5irxced2eddyq23jkp4csf5igoob7diq", "name": "age", }, { - "cid": "bafybeigmez6gtszsqx6aevzlanvpazhhezw5va4wizhqtqz5k4s2dqjb24", + "cid": "bafybeiehcr3diremeja2ndk2osux647v5fc7s353h7pbvrnsagw4paugku", "name": "name", }, }, @@ -75,8 +75,8 @@ func TestQueryLatestCommitsWithDocIDWithSchemaVersionIdField(t *testing.T) { }, Results: []map[string]any{ { - "cid": "bafybeiedu23doqe2nagdbmkvfyuouajnfxo7ezy57vbv34dqewhwbfg45u", - "schemaVersionId": "bafkreiayhdsgzhmrz6t5d3x2cgqqbdjt7aqgldtlkmxn5eibg542j3n6ea", + "cid": "bafybeiggrv6gyhld2dbkspaxsenjejfhnk52pm4mlpyz2q6x4dlnaff2mu", + "schemaVersionId": "bafkreidjvyxputjthx4wzyxtk33fce3shqguif3yhifykilybpn6canony", }, }, } diff --git a/tests/integration/query/one_to_many/with_cid_doc_id_test.go b/tests/integration/query/one_to_many/with_cid_doc_id_test.go index 92ec678468..269cdfabae 100644 --- a/tests/integration/query/one_to_many/with_cid_doc_id_test.go +++ b/tests/integration/query/one_to_many/with_cid_doc_id_test.go @@ -68,7 +68,7 @@ func TestQueryOneToManyWithCidAndDocID(t *testing.T) { Description: "One-to-many relation query from one side with cid and docID", Request: `query { Book ( - cid: "bafybeielrctlwgqx3o5cu3m2636fnfqcizayinyyuemaqhgdgy7ykfhyvi" + cid: "bafybeic2p6yvejdoprdkjtg5yy3lgs7t2hk5gfw4zzdl76f63befyh3imi" docID: "bae-b9b83269-1f28-5c3b-ae75-3fb4c00d559d" ) { name @@ -117,7 +117,7 @@ func TestQueryOneToManyWithChildUpdateAndFirstCidAndDocID(t *testing.T) { Description: "One-to-many relation query from one side with child update and parent cid and docID", Request: `query { Book ( - cid: "bafybeielrctlwgqx3o5cu3m2636fnfqcizayinyyuemaqhgdgy7ykfhyvi", + cid: "bafybeic2p6yvejdoprdkjtg5yy3lgs7t2hk5gfw4zzdl76f63befyh3imi", docID: "bae-b9b83269-1f28-5c3b-ae75-3fb4c00d559d" ) { name @@ -173,7 +173,7 @@ func TestQueryOneToManyWithParentUpdateAndFirstCidAndDocID(t *testing.T) { Description: "One-to-many relation query from one side with parent update and parent cid and docID", Request: `query { Book ( - cid: "bafybeiao32zf3tqrtutibbivxhk4fjjhsryb5q4mqyp3gecqp3s5tgegfy", + cid: "bafybeic2p6yvejdoprdkjtg5yy3lgs7t2hk5gfw4zzdl76f63befyh3imi", docID: "bae-b9b83269-1f28-5c3b-ae75-3fb4c00d559d" ) { name @@ -225,7 +225,7 @@ func TestQueryOneToManyWithParentUpdateAndLastCidAndDocID(t *testing.T) { Description: "One-to-many relation query from one side with parent update and parent cid and docID", Request: `query { Book ( - cid: "bafybeiao32zf3tqrtutibbivxhk4fjjhsryb5q4mqyp3gecqp3s5tgegfy", + cid: "bafybeieie7sfx727alq2njnhvvxg33aw2mn3fdj7eu4372lqoc45efwiaq", docID: "bae-b9b83269-1f28-5c3b-ae75-3fb4c00d559d" ) { name diff --git a/tests/integration/query/simple/with_cid_doc_id_test.go b/tests/integration/query/simple/with_cid_doc_id_test.go index 4b40c4d76d..992d3c3261 100644 --- a/tests/integration/query/simple/with_cid_doc_id_test.go +++ b/tests/integration/query/simple/with_cid_doc_id_test.go @@ -73,7 +73,7 @@ func TestQuerySimpleWithCidAndDocID(t *testing.T) { Description: "Simple query with cid and docID", Request: `query { Users ( - cid: "bafybeigwxfw2nfcwelqxzgjsmm5okrt7dctzvzml4tm7i7q7fsdit3ihz4", + cid: "bafybeib26cyuzbnf7uq3js5mykfveplsn4imo2fmf2jnnib6rrtnllv4pe", docID: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f" ) { Name @@ -102,7 +102,7 @@ func TestQuerySimpleWithUpdateAndFirstCidAndDocID(t *testing.T) { Description: "Simple query with (first) cid and docID", Request: `query { Users ( - cid: "bafybeigwxfw2nfcwelqxzgjsmm5okrt7dctzvzml4tm7i7q7fsdit3ihz4", + cid: "bafybeib26cyuzbnf7uq3js5mykfveplsn4imo2fmf2jnnib6rrtnllv4pe", docID: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f" ) { Name @@ -143,7 +143,7 @@ func TestQuerySimpleWithUpdateAndLastCidAndDocID(t *testing.T) { Description: "Simple query with (last) cid and docID", Request: `query { Users ( - cid: "bafybeigotwnjltl5y5ou5yqxujdayoqet4axspaclbvzustjhinzqx77ym" + cid: "bafybeicehye3yrct3yaumy64sucndh2ab7i6ymj72klfm2gphigjx6yw5u" docID: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f" ) { Name @@ -184,7 +184,7 @@ func TestQuerySimpleWithUpdateAndMiddleCidAndDocID(t *testing.T) { Description: "Simple query with (middle) cid and docID", Request: `query { Users ( - cid: "bafybeib4cdjv4dxmayzgf242hx2r3v5tq5ib5z6oyyrzk3dtddt3wsyyhi", + cid: "bafybeie23a5xsx4qyoffa3riij3kei5to54bb6gq7m4lftfjujaohkabwu", docID: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f" ) { Name @@ -225,7 +225,7 @@ func TestQuerySimpleWithUpdateAndFirstCidAndDocIDAndSchemaVersion(t *testing.T) Description: "Simple query with (first) cid and docID and yielded schema version", Request: `query { Users ( - cid: "bafybeigwxfw2nfcwelqxzgjsmm5okrt7dctzvzml4tm7i7q7fsdit3ihz4", + cid: "bafybeib26cyuzbnf7uq3js5mykfveplsn4imo2fmf2jnnib6rrtnllv4pe", docID: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f" ) { Name @@ -259,7 +259,7 @@ func TestQuerySimpleWithUpdateAndFirstCidAndDocIDAndSchemaVersion(t *testing.T) "Age": int64(21), "_version": []map[string]any{ { - "schemaVersionId": "bafkreidvd63bawkelxe3wtf7a65klkq4x3dvenqafyasndyal6fvffkeam", + "schemaVersionId": "bafkreihuvcb7e7vy6ua3yrwbwnul3djqrtbhyuv3c4dqe4y3i2ssudzveu", }, }, }, @@ -301,7 +301,7 @@ func TestCidAndDocIDQuery_ContainsPNCounterWithIntKind_NoError(t *testing.T) { testUtils.Request{ Request: `query { Users ( - cid: "bafybeiepi2gpoyshdj2ekdsydhw5itxqmipsh7f6pd6iyoiu6sqsdlj2se", + cid: "bafybeia4u3g4r3uolc7slho4thvhqfma5fkfrtho3lgapopatud2fl63lu", docID: "bae-a688789e-d8a6-57a7-be09-22e005ab79e0" ) { name @@ -353,7 +353,7 @@ func TestCidAndDocIDQuery_ContainsPNCounterWithFloatKind_NoError(t *testing.T) { testUtils.Request{ Request: `query { Users ( - cid: "bafybeihjdntxsc75hpnyakog4nnaxakljer7zf7pjybpgntcsg45qmisau", + cid: "bafybeicldbqzhmhu2hgowp6jazm4xpwh7tdurvc2xynuc54k4j7edn3vem", docID: "bae-fa6a97e9-e0e9-5826-8a8c-57775d35e07c" ) { name diff --git a/tests/integration/query/simple/with_version_test.go b/tests/integration/query/simple/with_version_test.go index a40c4d660f..de5f858089 100644 --- a/tests/integration/query/simple/with_version_test.go +++ b/tests/integration/query/simple/with_version_test.go @@ -46,14 +46,14 @@ func TestQuerySimpleWithEmbeddedLatestCommit(t *testing.T) { "Age": int64(21), "_version": []map[string]any{ { - "cid": "bafybeigwxfw2nfcwelqxzgjsmm5okrt7dctzvzml4tm7i7q7fsdit3ihz4", + "cid": "bafybeib26cyuzbnf7uq3js5mykfveplsn4imo2fmf2jnnib6rrtnllv4pe", "links": []map[string]any{ { - "cid": "bafybeigcmjyt2ux4mzfckbsz5snkoqrr42vfkesgk7rdw6xzblrowrzfg4", + "cid": "bafybeihkhgtdogxwqe2lkjqord5bzthfwwthyo3gu6iljfm5l7n7fkhpsq", "name": "Age", }, { - "cid": "bafybeihkekm4kfn2ttx3wb33l2ps7aductuzd7hrmu6n7zloaicrj5n75u", + "cid": "bafybeico2g2tdkpo4i64ph6b5vgngn5zbxus4jxwav3bi2joieqicplfxi", "name": "Name", }, }, @@ -90,7 +90,7 @@ func TestQuerySimpleWithEmbeddedLatestCommitWithSchemaVersionId(t *testing.T) { "Name": "John", "_version": []map[string]any{ { - "schemaVersionId": "bafkreidvd63bawkelxe3wtf7a65klkq4x3dvenqafyasndyal6fvffkeam", + "schemaVersionId": "bafkreihuvcb7e7vy6ua3yrwbwnul3djqrtbhyuv3c4dqe4y3i2ssudzveu", }, }, }, @@ -171,14 +171,14 @@ func TestQuerySimpleWithMultipleAliasedEmbeddedLatestCommit(t *testing.T) { "Age": int64(21), "_version": []map[string]any{ { - "cid": "bafybeigwxfw2nfcwelqxzgjsmm5okrt7dctzvzml4tm7i7q7fsdit3ihz4", + "cid": "bafybeib26cyuzbnf7uq3js5mykfveplsn4imo2fmf2jnnib6rrtnllv4pe", "L1": []map[string]any{ { - "cid": "bafybeigcmjyt2ux4mzfckbsz5snkoqrr42vfkesgk7rdw6xzblrowrzfg4", + "cid": "bafybeihkhgtdogxwqe2lkjqord5bzthfwwthyo3gu6iljfm5l7n7fkhpsq", "name": "Age", }, { - "cid": "bafybeihkekm4kfn2ttx3wb33l2ps7aductuzd7hrmu6n7zloaicrj5n75u", + "cid": "bafybeico2g2tdkpo4i64ph6b5vgngn5zbxus4jxwav3bi2joieqicplfxi", "name": "Name", }, }, diff --git a/tests/integration/schema/crdt_type_test.go b/tests/integration/schema/crdt_type_test.go index d09d406161..0611882cc1 100644 --- a/tests/integration/schema/crdt_type_test.go +++ b/tests/integration/schema/crdt_type_test.go @@ -20,7 +20,7 @@ import ( ) func TestSchemaCreate_ContainsPNCounterTypeWithIntKind_NoError(t *testing.T) { - schemaVersionID := "bafkreig54q5pw7elljueepsyux4qgdspm3ozct5dqocr5b2kufpjwb2mae" + schemaVersionID := "bafkreicawqdqtzuw5dvhb7jg2u4yheu7yhigciocode4kyvfyrq57mtxty" test := testUtils.TestCase{ Actions: []any{ @@ -60,7 +60,7 @@ func TestSchemaCreate_ContainsPNCounterTypeWithIntKind_NoError(t *testing.T) { } func TestSchemaCreate_ContainsPNCounterTypeWithFloatKind_NoError(t *testing.T) { - schemaVersionID := "bafkreibaeypr2i2eg3kozq3mlfsibgtolqlrcozo5ufqfb725dfq3hx43e" + schemaVersionID := "bafkreica5ubot4w4bwpei5afvhf3obfveob5jotjyqzrcc47spargaznae" test := testUtils.TestCase{ Actions: []any{ diff --git a/tests/integration/schema/get_schema_test.go b/tests/integration/schema/get_schema_test.go index 42f42e4844..a9520cbed7 100644 --- a/tests/integration/schema/get_schema_test.go +++ b/tests/integration/schema/get_schema_test.go @@ -71,9 +71,9 @@ func TestGetSchema_GivenNoSchemaGivenUnknownName(t *testing.T) { } func TestGetSchema_ReturnsAllSchema(t *testing.T) { - usersSchemaVersion1ID := "bafkreicavrlknsnfqey6nfwthyiguvv4dqcwhvywl5j6socx3vvjt4zqte" - usersSchemaVersion2ID := "bafkreiabmj6ypcc6alqswrscgpj6rqbhogsojgv7fopr5rgrluvxtwente" - booksSchemaVersion1ID := "bafkreiaiku34mjr2za5yo6yc4pzoupenwzjq7d5pclgfdiihdnjq33fn5y" + usersSchemaVersion1ID := "bafkreiagl4ml2ll45ex6g62bunpfs6o4mr2zstfuegwtxktm52stq6abxi" + usersSchemaVersion2ID := "bafkreib7rfcyxx5anpl3ikvi5g63jv6gtgwywtt6usrng2pdg4j5jwjlsa" + booksSchemaVersion1ID := "bafkreic3guyvlavrp7pq23s2uftvk5tx2gq2hs5ikbadtaghbafpkfox34" test := testUtils.TestCase{ Actions: []any{ @@ -97,6 +97,17 @@ func TestGetSchema_ReturnsAllSchema(t *testing.T) { }, testUtils.GetSchema{ ExpectedResults: []client.SchemaDescription{ + { + Name: "Users", + Root: usersSchemaVersion1ID, + VersionID: usersSchemaVersion1ID, + Fields: []client.FieldDescription{ + { + Name: "_docID", + Kind: client.FieldKind_DocID, + }, + }, + }, { Name: "Users", Root: usersSchemaVersion1ID, @@ -126,17 +137,6 @@ func TestGetSchema_ReturnsAllSchema(t *testing.T) { }, }, }, - { - Name: "Users", - Root: usersSchemaVersion1ID, - VersionID: usersSchemaVersion1ID, - Fields: []client.FieldDescription{ - { - Name: "_docID", - Kind: client.FieldKind_DocID, - }, - }, - }, }, }, }, @@ -146,8 +146,8 @@ func TestGetSchema_ReturnsAllSchema(t *testing.T) { } func TestGetSchema_ReturnsSchemaForGivenRoot(t *testing.T) { - usersSchemaVersion1ID := "bafkreicavrlknsnfqey6nfwthyiguvv4dqcwhvywl5j6socx3vvjt4zqte" - usersSchemaVersion2ID := "bafkreiabmj6ypcc6alqswrscgpj6rqbhogsojgv7fopr5rgrluvxtwente" + usersSchemaVersion1ID := "bafkreiagl4ml2ll45ex6g62bunpfs6o4mr2zstfuegwtxktm52stq6abxi" + usersSchemaVersion2ID := "bafkreib7rfcyxx5anpl3ikvi5g63jv6gtgwywtt6usrng2pdg4j5jwjlsa" test := testUtils.TestCase{ Actions: []any{ @@ -175,29 +175,29 @@ func TestGetSchema_ReturnsSchemaForGivenRoot(t *testing.T) { { Name: "Users", Root: usersSchemaVersion1ID, - VersionID: usersSchemaVersion2ID, + VersionID: usersSchemaVersion1ID, Fields: []client.FieldDescription{ { Name: "_docID", Kind: client.FieldKind_DocID, - Typ: client.LWW_REGISTER, - }, - { - Name: "name", - ID: 1, - Kind: client.FieldKind_NILLABLE_STRING, - Typ: client.LWW_REGISTER, }, }, }, { Name: "Users", Root: usersSchemaVersion1ID, - VersionID: usersSchemaVersion1ID, + VersionID: usersSchemaVersion2ID, Fields: []client.FieldDescription{ { Name: "_docID", Kind: client.FieldKind_DocID, + Typ: client.LWW_REGISTER, + }, + { + Name: "name", + ID: 1, + Kind: client.FieldKind_NILLABLE_STRING, + Typ: client.LWW_REGISTER, }, }, }, @@ -210,8 +210,8 @@ func TestGetSchema_ReturnsSchemaForGivenRoot(t *testing.T) { } func TestGetSchema_ReturnsSchemaForGivenName(t *testing.T) { - usersSchemaVersion1ID := "bafkreicavrlknsnfqey6nfwthyiguvv4dqcwhvywl5j6socx3vvjt4zqte" - usersSchemaVersion2ID := "bafkreiabmj6ypcc6alqswrscgpj6rqbhogsojgv7fopr5rgrluvxtwente" + usersSchemaVersion1ID := "bafkreiagl4ml2ll45ex6g62bunpfs6o4mr2zstfuegwtxktm52stq6abxi" + usersSchemaVersion2ID := "bafkreib7rfcyxx5anpl3ikvi5g63jv6gtgwywtt6usrng2pdg4j5jwjlsa" test := testUtils.TestCase{ Actions: []any{ @@ -239,29 +239,29 @@ func TestGetSchema_ReturnsSchemaForGivenName(t *testing.T) { { Name: "Users", Root: usersSchemaVersion1ID, - VersionID: usersSchemaVersion2ID, + VersionID: usersSchemaVersion1ID, Fields: []client.FieldDescription{ { Name: "_docID", Kind: client.FieldKind_DocID, - Typ: client.LWW_REGISTER, - }, - { - Name: "name", - ID: 1, - Kind: client.FieldKind_NILLABLE_STRING, - Typ: client.LWW_REGISTER, }, }, }, { Name: "Users", Root: usersSchemaVersion1ID, - VersionID: usersSchemaVersion1ID, + VersionID: usersSchemaVersion2ID, Fields: []client.FieldDescription{ { Name: "_docID", Kind: client.FieldKind_DocID, + Typ: client.LWW_REGISTER, + }, + { + Name: "name", + ID: 1, + Kind: client.FieldKind_NILLABLE_STRING, + Typ: client.LWW_REGISTER, }, }, }, diff --git a/tests/integration/schema/migrations/query/simple_test.go b/tests/integration/schema/migrations/query/simple_test.go index b758356cac..960d907170 100644 --- a/tests/integration/schema/migrations/query/simple_test.go +++ b/tests/integration/schema/migrations/query/simple_test.go @@ -45,8 +45,8 @@ func TestSchemaMigrationQuery(t *testing.T) { }, testUtils.ConfigureMigration{ LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreig3zt63qt7bkji47etyu2sqtzroa3tcfdxgwqc3ka2ijy63refq3a", - DestinationSchemaVersionID: "bafkreia4m6sn2rfypj2velvwpyude22fcb5jyfzum2eh3cdzg4a3myj5nu", + SourceSchemaVersionID: "bafkreibjb4h5nudsei7cq2kkontjinmjpbqls2tmowqp5nxougu4tuus4i", + DestinationSchemaVersionID: "bafkreih6o2jyurelxtpbg66gk23pio2tq6o3aed334z6w2u3qwve3at7ku", Lens: model.Lens{ Lenses: []model.LensModule{ { @@ -115,8 +115,8 @@ func TestSchemaMigrationQueryMultipleDocs(t *testing.T) { }, testUtils.ConfigureMigration{ LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreig3zt63qt7bkji47etyu2sqtzroa3tcfdxgwqc3ka2ijy63refq3a", - DestinationSchemaVersionID: "bafkreia4m6sn2rfypj2velvwpyude22fcb5jyfzum2eh3cdzg4a3myj5nu", + SourceSchemaVersionID: "bafkreibjb4h5nudsei7cq2kkontjinmjpbqls2tmowqp5nxougu4tuus4i", + DestinationSchemaVersionID: "bafkreih6o2jyurelxtpbg66gk23pio2tq6o3aed334z6w2u3qwve3at7ku", Lens: model.Lens{ Lenses: []model.LensModule{ { @@ -178,8 +178,8 @@ func TestSchemaMigrationQueryWithMigrationRegisteredBeforeSchemaPatch(t *testing }, testUtils.ConfigureMigration{ LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreig3zt63qt7bkji47etyu2sqtzroa3tcfdxgwqc3ka2ijy63refq3a", - DestinationSchemaVersionID: "bafkreia4m6sn2rfypj2velvwpyude22fcb5jyfzum2eh3cdzg4a3myj5nu", + SourceSchemaVersionID: "bafkreibjb4h5nudsei7cq2kkontjinmjpbqls2tmowqp5nxougu4tuus4i", + DestinationSchemaVersionID: "bafkreih6o2jyurelxtpbg66gk23pio2tq6o3aed334z6w2u3qwve3at7ku", Lens: model.Lens{ Lenses: []model.LensModule{ { @@ -254,8 +254,8 @@ func TestSchemaMigrationQueryMigratesToIntermediaryVersion(t *testing.T) { // Register a migration from schema version 1 to schema version 2 **only** - // there should be no migration from version 2 to version 3. LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreig3zt63qt7bkji47etyu2sqtzroa3tcfdxgwqc3ka2ijy63refq3a", - DestinationSchemaVersionID: "bafkreia4m6sn2rfypj2velvwpyude22fcb5jyfzum2eh3cdzg4a3myj5nu", + SourceSchemaVersionID: "bafkreibjb4h5nudsei7cq2kkontjinmjpbqls2tmowqp5nxougu4tuus4i", + DestinationSchemaVersionID: "bafkreih6o2jyurelxtpbg66gk23pio2tq6o3aed334z6w2u3qwve3at7ku", Lens: model.Lens{ Lenses: []model.LensModule{ { @@ -325,8 +325,8 @@ func TestSchemaMigrationQueryMigratesFromIntermediaryVersion(t *testing.T) { // Register a migration from schema version 2 to schema version 3 **only** - // there should be no migration from version 1 to version 2. LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreia4m6sn2rfypj2velvwpyude22fcb5jyfzum2eh3cdzg4a3myj5nu", - DestinationSchemaVersionID: "bafkreigrpkox3omi3c3sp5zoupcjg2b32mysztjozaqsceafsdtkadzufe", + SourceSchemaVersionID: "bafkreih6o2jyurelxtpbg66gk23pio2tq6o3aed334z6w2u3qwve3at7ku", + DestinationSchemaVersionID: "bafkreihv4ktjwzyhhkmas5iz4q7cawet4aeurqci33i66wr225l5pet4qu", Lens: model.Lens{ Lenses: []model.LensModule{ { @@ -394,8 +394,8 @@ func TestSchemaMigrationQueryMigratesAcrossMultipleVersions(t *testing.T) { }, testUtils.ConfigureMigration{ LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreig3zt63qt7bkji47etyu2sqtzroa3tcfdxgwqc3ka2ijy63refq3a", - DestinationSchemaVersionID: "bafkreia4m6sn2rfypj2velvwpyude22fcb5jyfzum2eh3cdzg4a3myj5nu", + SourceSchemaVersionID: "bafkreibjb4h5nudsei7cq2kkontjinmjpbqls2tmowqp5nxougu4tuus4i", + DestinationSchemaVersionID: "bafkreih6o2jyurelxtpbg66gk23pio2tq6o3aed334z6w2u3qwve3at7ku", Lens: model.Lens{ Lenses: []model.LensModule{ { @@ -411,8 +411,8 @@ func TestSchemaMigrationQueryMigratesAcrossMultipleVersions(t *testing.T) { }, testUtils.ConfigureMigration{ LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreia4m6sn2rfypj2velvwpyude22fcb5jyfzum2eh3cdzg4a3myj5nu", - DestinationSchemaVersionID: "bafkreigrpkox3omi3c3sp5zoupcjg2b32mysztjozaqsceafsdtkadzufe", + SourceSchemaVersionID: "bafkreih6o2jyurelxtpbg66gk23pio2tq6o3aed334z6w2u3qwve3at7ku", + DestinationSchemaVersionID: "bafkreihv4ktjwzyhhkmas5iz4q7cawet4aeurqci33i66wr225l5pet4qu", Lens: model.Lens{ Lenses: []model.LensModule{ { @@ -539,8 +539,8 @@ func TestSchemaMigrationQueryMigrationMutatesExistingScalarField(t *testing.T) { }, testUtils.ConfigureMigration{ LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreig3zt63qt7bkji47etyu2sqtzroa3tcfdxgwqc3ka2ijy63refq3a", - DestinationSchemaVersionID: "bafkreia4m6sn2rfypj2velvwpyude22fcb5jyfzum2eh3cdzg4a3myj5nu", + SourceSchemaVersionID: "bafkreibjb4h5nudsei7cq2kkontjinmjpbqls2tmowqp5nxougu4tuus4i", + DestinationSchemaVersionID: "bafkreih6o2jyurelxtpbg66gk23pio2tq6o3aed334z6w2u3qwve3at7ku", Lens: model.Lens{ Lenses: []model.LensModule{ { @@ -600,8 +600,8 @@ func TestSchemaMigrationQueryMigrationMutatesExistingInlineArrayField(t *testing }, testUtils.ConfigureMigration{ LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreigjtl5r3lq6dkbod766let7ewqirc2ai6l2c5j5fxxc43zmvqqs24", - DestinationSchemaVersionID: "bafkreicwipnhoplttqy7spj2ksgk7vwmxmdtwt6g23os2kmqgvb22wfg3m", + SourceSchemaVersionID: "bafkreic2fcxa2e7o2acur6yh6iv7vyso4ecgfcqbbp6l55twpgdumdctui", + DestinationSchemaVersionID: "bafkreidz6fo522l4vzsdbe4b5mhm3c7tc5xmve7i2egsk4s53zg6emkbyy", Lens: model.Lens{ Lenses: []model.LensModule{ { @@ -663,7 +663,7 @@ func TestSchemaMigrationQueryMigrationRemovesExistingField(t *testing.T) { }, testUtils.ConfigureMigration{ LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreicnoqat3exmvikr36xu3hhrkvay3d3cif24tezgsyvrydpobk2nqm", + SourceSchemaVersionID: "bafkreihh4zkyuqk4ibwb5utyayvbw75hdfkueg3scm7taysk3rbh2jhaee", DestinationSchemaVersionID: "bafkreigamaevrkcknutb275x3uxpgc2sn73qsfvkjqli7fiqaxfnniunjy", Lens: model.Lens{ Lenses: []model.LensModule{ @@ -724,7 +724,7 @@ func TestSchemaMigrationQueryMigrationPreservesExistingFieldWhenFieldNotRequeste }, testUtils.ConfigureMigration{ LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreicnoqat3exmvikr36xu3hhrkvay3d3cif24tezgsyvrydpobk2nqm", + SourceSchemaVersionID: "bafkreihh4zkyuqk4ibwb5utyayvbw75hdfkueg3scm7taysk3rbh2jhaee", DestinationSchemaVersionID: "bafkreigamaevrkcknutb275x3uxpgc2sn73qsfvkjqli7fiqaxfnniunjy", Lens: model.Lens{ Lenses: []model.LensModule{ @@ -798,7 +798,7 @@ func TestSchemaMigrationQueryMigrationCopiesExistingFieldWhenSrcFieldNotRequeste }, testUtils.ConfigureMigration{ LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreicnoqat3exmvikr36xu3hhrkvay3d3cif24tezgsyvrydpobk2nqm", + SourceSchemaVersionID: "bafkreihh4zkyuqk4ibwb5utyayvbw75hdfkueg3scm7taysk3rbh2jhaee", DestinationSchemaVersionID: "bafkreigamaevrkcknutb275x3uxpgc2sn73qsfvkjqli7fiqaxfnniunjy", Lens: model.Lens{ Lenses: []model.LensModule{ @@ -860,7 +860,7 @@ func TestSchemaMigrationQueryMigrationCopiesExistingFieldWhenSrcAndDstFieldNotRe }, testUtils.ConfigureMigration{ LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreicnoqat3exmvikr36xu3hhrkvay3d3cif24tezgsyvrydpobk2nqm", + SourceSchemaVersionID: "bafkreihh4zkyuqk4ibwb5utyayvbw75hdfkueg3scm7taysk3rbh2jhaee", DestinationSchemaVersionID: "bafkreigamaevrkcknutb275x3uxpgc2sn73qsfvkjqli7fiqaxfnniunjy", Lens: model.Lens{ Lenses: []model.LensModule{ diff --git a/tests/integration/schema/migrations/query/with_doc_id_test.go b/tests/integration/schema/migrations/query/with_doc_id_test.go index 2ce1fd8ac3..f1b66b22d3 100644 --- a/tests/integration/schema/migrations/query/with_doc_id_test.go +++ b/tests/integration/schema/migrations/query/with_doc_id_test.go @@ -52,8 +52,8 @@ func TestSchemaMigrationQueryByDocID(t *testing.T) { }, testUtils.ConfigureMigration{ LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreig3zt63qt7bkji47etyu2sqtzroa3tcfdxgwqc3ka2ijy63refq3a", - DestinationSchemaVersionID: "bafkreia4m6sn2rfypj2velvwpyude22fcb5jyfzum2eh3cdzg4a3myj5nu", + SourceSchemaVersionID: "bafkreibjb4h5nudsei7cq2kkontjinmjpbqls2tmowqp5nxougu4tuus4i", + DestinationSchemaVersionID: "bafkreih6o2jyurelxtpbg66gk23pio2tq6o3aed334z6w2u3qwve3at7ku", Lens: model.Lens{ Lenses: []model.LensModule{ { @@ -158,8 +158,8 @@ func TestSchemaMigrationQueryMultipleQueriesByDocID(t *testing.T) { }, testUtils.ConfigureMigration{ LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreig3zt63qt7bkji47etyu2sqtzroa3tcfdxgwqc3ka2ijy63refq3a", - DestinationSchemaVersionID: "bafkreia4m6sn2rfypj2velvwpyude22fcb5jyfzum2eh3cdzg4a3myj5nu", + SourceSchemaVersionID: "bafkreibjb4h5nudsei7cq2kkontjinmjpbqls2tmowqp5nxougu4tuus4i", + DestinationSchemaVersionID: "bafkreih6o2jyurelxtpbg66gk23pio2tq6o3aed334z6w2u3qwve3at7ku", Lens: model.Lens{ Lenses: []model.LensModule{ { diff --git a/tests/integration/schema/migrations/query/with_p2p_test.go b/tests/integration/schema/migrations/query/with_p2p_test.go index 4b06bf6586..9c39da5dff 100644 --- a/tests/integration/schema/migrations/query/with_p2p_test.go +++ b/tests/integration/schema/migrations/query/with_p2p_test.go @@ -46,8 +46,8 @@ func TestSchemaMigrationQueryWithP2PReplicatedDocAtOlderSchemaVersion(t *testing testUtils.ConfigureMigration{ // Register the migration on both nodes. LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreibgg4ex7aya4w4x3dnrlyov4juyuffjjokzkjrpoupncfuvsyi6du", - DestinationSchemaVersionID: "bafkreidvp3xozpau2zanh7s5or4fhr7kchm6klznsyzd7fpcm3sh2xlgfm", + SourceSchemaVersionID: "bafkreiadnck34zzbwayjw3aeubw7eg4jmgtwoibu35tkxbjpar5rzxkdpu", + DestinationSchemaVersionID: "bafkreibzqyjmyjs7vyo2q4h2tv5rbdbe4lv7tjbl5esilmobhgclia2juy", Lens: model.Lens{ Lenses: []model.LensModule{ { @@ -136,8 +136,8 @@ func TestSchemaMigrationQueryWithP2PReplicatedDocAtNewerSchemaVersion(t *testing testUtils.ConfigureMigration{ // Register the migration on both nodes. LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreibgg4ex7aya4w4x3dnrlyov4juyuffjjokzkjrpoupncfuvsyi6du", - DestinationSchemaVersionID: "bafkreidvp3xozpau2zanh7s5or4fhr7kchm6klznsyzd7fpcm3sh2xlgfm", + SourceSchemaVersionID: "bafkreiadnck34zzbwayjw3aeubw7eg4jmgtwoibu35tkxbjpar5rzxkdpu", + DestinationSchemaVersionID: "bafkreibzqyjmyjs7vyo2q4h2tv5rbdbe4lv7tjbl5esilmobhgclia2juy", Lens: model.Lens{ Lenses: []model.LensModule{ { @@ -238,8 +238,8 @@ func TestSchemaMigrationQueryWithP2PReplicatedDocAtMuchNewerSchemaVersionWithSch // Register a migration from version 2 to version 3 on both nodes. // There is no migration from version 1 to 2, thus node 1 has no knowledge of schema version 2. LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreia4m6sn2rfypj2velvwpyude22fcb5jyfzum2eh3cdzg4a3myj5nu", - DestinationSchemaVersionID: "bafkreigrpkox3omi3c3sp5zoupcjg2b32mysztjozaqsceafsdtkadzufe", + SourceSchemaVersionID: "bafkreih6o2jyurelxtpbg66gk23pio2tq6o3aed334z6w2u3qwve3at7ku", + DestinationSchemaVersionID: "bafkreihv4ktjwzyhhkmas5iz4q7cawet4aeurqci33i66wr225l5pet4qu", Lens: model.Lens{ Lenses: []model.LensModule{ { diff --git a/tests/integration/schema/migrations/query/with_restart_test.go b/tests/integration/schema/migrations/query/with_restart_test.go index 3b51c92ada..300c84bade 100644 --- a/tests/integration/schema/migrations/query/with_restart_test.go +++ b/tests/integration/schema/migrations/query/with_restart_test.go @@ -45,8 +45,8 @@ func TestSchemaMigrationQueryWithRestart(t *testing.T) { }, testUtils.ConfigureMigration{ LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreig3zt63qt7bkji47etyu2sqtzroa3tcfdxgwqc3ka2ijy63refq3a", - DestinationSchemaVersionID: "bafkreia4m6sn2rfypj2velvwpyude22fcb5jyfzum2eh3cdzg4a3myj5nu", + SourceSchemaVersionID: "bafkreibjb4h5nudsei7cq2kkontjinmjpbqls2tmowqp5nxougu4tuus4i", + DestinationSchemaVersionID: "bafkreih6o2jyurelxtpbg66gk23pio2tq6o3aed334z6w2u3qwve3at7ku", Lens: model.Lens{ Lenses: []model.LensModule{ { diff --git a/tests/integration/schema/migrations/query/with_set_default_test.go b/tests/integration/schema/migrations/query/with_set_default_test.go index 55a3fc9968..cd272fc860 100644 --- a/tests/integration/schema/migrations/query/with_set_default_test.go +++ b/tests/integration/schema/migrations/query/with_set_default_test.go @@ -22,7 +22,7 @@ import ( ) func TestSchemaMigrationQuery_WithSetDefaultToLatest_AppliesForwardMigration(t *testing.T) { - schemaVersionID2 := "bafkreidvp3xozpau2zanh7s5or4fhr7kchm6klznsyzd7fpcm3sh2xlgfm" + schemaVersionID2 := "bafkreibzqyjmyjs7vyo2q4h2tv5rbdbe4lv7tjbl5esilmobhgclia2juy" test := testUtils.TestCase{ Description: "Test schema migration", @@ -50,7 +50,7 @@ func TestSchemaMigrationQuery_WithSetDefaultToLatest_AppliesForwardMigration(t * }, testUtils.ConfigureMigration{ LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreibgg4ex7aya4w4x3dnrlyov4juyuffjjokzkjrpoupncfuvsyi6du", + SourceSchemaVersionID: "bafkreiadnck34zzbwayjw3aeubw7eg4jmgtwoibu35tkxbjpar5rzxkdpu", DestinationSchemaVersionID: schemaVersionID2, Lens: model.Lens{ Lenses: []model.LensModule{ @@ -89,8 +89,8 @@ func TestSchemaMigrationQuery_WithSetDefaultToLatest_AppliesForwardMigration(t * } func TestSchemaMigrationQuery_WithSetDefaultToOriginal_AppliesInverseMigration(t *testing.T) { - schemaVersionID1 := "bafkreibgg4ex7aya4w4x3dnrlyov4juyuffjjokzkjrpoupncfuvsyi6du" - schemaVersionID2 := "bafkreidvp3xozpau2zanh7s5or4fhr7kchm6klznsyzd7fpcm3sh2xlgfm" + schemaVersionID1 := "bafkreiadnck34zzbwayjw3aeubw7eg4jmgtwoibu35tkxbjpar5rzxkdpu" + schemaVersionID2 := "bafkreibzqyjmyjs7vyo2q4h2tv5rbdbe4lv7tjbl5esilmobhgclia2juy" test := testUtils.TestCase{ Description: "Test schema migration", @@ -164,8 +164,8 @@ func TestSchemaMigrationQuery_WithSetDefaultToOriginal_AppliesInverseMigration(t } func TestSchemaMigrationQuery_WithSetDefaultToOriginalVersionThatDocWasCreatedAt_ClearsMigrations(t *testing.T) { - schemaVersionID1 := "bafkreibgg4ex7aya4w4x3dnrlyov4juyuffjjokzkjrpoupncfuvsyi6du" - schemaVersionID2 := "bafkreidvp3xozpau2zanh7s5or4fhr7kchm6klznsyzd7fpcm3sh2xlgfm" + schemaVersionID1 := "bafkreiadnck34zzbwayjw3aeubw7eg4jmgtwoibu35tkxbjpar5rzxkdpu" + schemaVersionID2 := "bafkreibzqyjmyjs7vyo2q4h2tv5rbdbe4lv7tjbl5esilmobhgclia2juy" test := testUtils.TestCase{ Description: "Test schema migration", diff --git a/tests/integration/schema/migrations/query/with_txn_test.go b/tests/integration/schema/migrations/query/with_txn_test.go index 4bb0395365..c7bd440120 100644 --- a/tests/integration/schema/migrations/query/with_txn_test.go +++ b/tests/integration/schema/migrations/query/with_txn_test.go @@ -47,8 +47,8 @@ func TestSchemaMigrationQueryWithTxn(t *testing.T) { testUtils.ConfigureMigration{ TransactionID: immutable.Some(0), LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreig3zt63qt7bkji47etyu2sqtzroa3tcfdxgwqc3ka2ijy63refq3a", - DestinationSchemaVersionID: "bafkreia4m6sn2rfypj2velvwpyude22fcb5jyfzum2eh3cdzg4a3myj5nu", + SourceSchemaVersionID: "bafkreibjb4h5nudsei7cq2kkontjinmjpbqls2tmowqp5nxougu4tuus4i", + DestinationSchemaVersionID: "bafkreih6o2jyurelxtpbg66gk23pio2tq6o3aed334z6w2u3qwve3at7ku", Lens: model.Lens{ Lenses: []model.LensModule{ { @@ -109,8 +109,8 @@ func TestSchemaMigrationQueryWithTxnAndCommit(t *testing.T) { testUtils.ConfigureMigration{ TransactionID: immutable.Some(0), LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreig3zt63qt7bkji47etyu2sqtzroa3tcfdxgwqc3ka2ijy63refq3a", - DestinationSchemaVersionID: "bafkreia4m6sn2rfypj2velvwpyude22fcb5jyfzum2eh3cdzg4a3myj5nu", + SourceSchemaVersionID: "bafkreibjb4h5nudsei7cq2kkontjinmjpbqls2tmowqp5nxougu4tuus4i", + DestinationSchemaVersionID: "bafkreih6o2jyurelxtpbg66gk23pio2tq6o3aed334z6w2u3qwve3at7ku", Lens: model.Lens{ Lenses: []model.LensModule{ { diff --git a/tests/integration/schema/migrations/query/with_update_test.go b/tests/integration/schema/migrations/query/with_update_test.go index 1c5c8e87a9..a3e7838297 100644 --- a/tests/integration/schema/migrations/query/with_update_test.go +++ b/tests/integration/schema/migrations/query/with_update_test.go @@ -45,8 +45,8 @@ func TestSchemaMigrationQueryWithUpdateRequest(t *testing.T) { }, testUtils.ConfigureMigration{ LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreig3zt63qt7bkji47etyu2sqtzroa3tcfdxgwqc3ka2ijy63refq3a", - DestinationSchemaVersionID: "bafkreia4m6sn2rfypj2velvwpyude22fcb5jyfzum2eh3cdzg4a3myj5nu", + SourceSchemaVersionID: "bafkreibjb4h5nudsei7cq2kkontjinmjpbqls2tmowqp5nxougu4tuus4i", + DestinationSchemaVersionID: "bafkreih6o2jyurelxtpbg66gk23pio2tq6o3aed334z6w2u3qwve3at7ku", Lens: model.Lens{ Lenses: []model.LensModule{ { @@ -129,8 +129,8 @@ func TestSchemaMigrationQueryWithMigrationRegisteredAfterUpdate(t *testing.T) { }, testUtils.ConfigureMigration{ LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreig3zt63qt7bkji47etyu2sqtzroa3tcfdxgwqc3ka2ijy63refq3a", - DestinationSchemaVersionID: "bafkreia4m6sn2rfypj2velvwpyude22fcb5jyfzum2eh3cdzg4a3myj5nu", + SourceSchemaVersionID: "bafkreibjb4h5nudsei7cq2kkontjinmjpbqls2tmowqp5nxougu4tuus4i", + DestinationSchemaVersionID: "bafkreih6o2jyurelxtpbg66gk23pio2tq6o3aed334z6w2u3qwve3at7ku", Lens: model.Lens{ Lenses: []model.LensModule{ { diff --git a/tests/integration/schema/migrations/simple_test.go b/tests/integration/schema/migrations/simple_test.go index 29769f1bac..172b3d3503 100644 --- a/tests/integration/schema/migrations/simple_test.go +++ b/tests/integration/schema/migrations/simple_test.go @@ -91,8 +91,8 @@ func TestSchemaMigrationGetMigrationsReturnsMultiple(t *testing.T) { }, testUtils.ConfigureMigration{ LensConfig: client.LensConfig{ - SourceSchemaVersionID: "bafkreig3zt63qt7bkji47etyu2sqtzroa3tcfdxgwqc3ka2ijy63refq3a", - DestinationSchemaVersionID: "bafkreia4m6sn2rfypj2velvwpyude22fcb5jyfzum2eh3cdzg4a3myj5nu", + SourceSchemaVersionID: "bafkreibjb4h5nudsei7cq2kkontjinmjpbqls2tmowqp5nxougu4tuus4i", + DestinationSchemaVersionID: "bafkreih6o2jyurelxtpbg66gk23pio2tq6o3aed334z6w2u3qwve3at7ku", Lens: model.Lens{ Lenses: []model.LensModule{ { @@ -124,8 +124,8 @@ func TestSchemaMigrationGetMigrationsReturnsMultiple(t *testing.T) { }, }, { - SourceSchemaVersionID: "bafkreig3zt63qt7bkji47etyu2sqtzroa3tcfdxgwqc3ka2ijy63refq3a", - DestinationSchemaVersionID: "bafkreia4m6sn2rfypj2velvwpyude22fcb5jyfzum2eh3cdzg4a3myj5nu", + SourceSchemaVersionID: "bafkreibjb4h5nudsei7cq2kkontjinmjpbqls2tmowqp5nxougu4tuus4i", + DestinationSchemaVersionID: "bafkreih6o2jyurelxtpbg66gk23pio2tq6o3aed334z6w2u3qwve3at7ku", Lens: model.Lens{ Lenses: []model.LensModule{ { diff --git a/tests/integration/schema/simple_test.go b/tests/integration/schema/simple_test.go index dccec9c4dd..2aec67a3ab 100644 --- a/tests/integration/schema/simple_test.go +++ b/tests/integration/schema/simple_test.go @@ -20,7 +20,7 @@ import ( ) func TestSchemaSimpleCreatesSchemaGivenEmptyType(t *testing.T) { - schemaVersionID := "bafkreicavrlknsnfqey6nfwthyiguvv4dqcwhvywl5j6socx3vvjt4zqte" + schemaVersionID := "bafkreiagl4ml2ll45ex6g62bunpfs6o4mr2zstfuegwtxktm52stq6abxi" test := testUtils.TestCase{ Actions: []any{ diff --git a/tests/integration/schema/updates/add/field/create_update_test.go b/tests/integration/schema/updates/add/field/create_update_test.go index 12cf973d59..19800ad4e6 100644 --- a/tests/integration/schema/updates/add/field/create_update_test.go +++ b/tests/integration/schema/updates/add/field/create_update_test.go @@ -17,8 +17,8 @@ import ( ) func TestSchemaUpdatesAddFieldWithCreateWithUpdateAfterSchemaUpdateAndVersionJoin(t *testing.T) { - initialSchemaVersionId := "bafkreig3zt63qt7bkji47etyu2sqtzroa3tcfdxgwqc3ka2ijy63refq3a" - updatedSchemaVersionId := "bafkreiclwd4nrvczrzy7aj52olojyzvgm4ht6jpktwpxuqej5wk3ocxpqi" + initialSchemaVersionId := "bafkreibjb4h5nudsei7cq2kkontjinmjpbqls2tmowqp5nxougu4tuus4i" + updatedSchemaVersionId := "bafkreibzozorw6lqjn5bjogsqxeqcswoqedcatdvphhts4frd7mb4jn7x4" test := testUtils.TestCase{ Description: "Test schema update, add field with update after schema update, version join", @@ -105,8 +105,8 @@ func TestSchemaUpdatesAddFieldWithCreateWithUpdateAfterSchemaUpdateAndVersionJoi } func TestSchemaUpdatesAddFieldWithCreateWithUpdateAfterSchemaUpdateAndCommitQuery(t *testing.T) { - initialSchemaVersionId := "bafkreig3zt63qt7bkji47etyu2sqtzroa3tcfdxgwqc3ka2ijy63refq3a" - updatedSchemaVersionId := "bafkreiclwd4nrvczrzy7aj52olojyzvgm4ht6jpktwpxuqej5wk3ocxpqi" + initialSchemaVersionId := "bafkreibjb4h5nudsei7cq2kkontjinmjpbqls2tmowqp5nxougu4tuus4i" + updatedSchemaVersionId := "bafkreibzozorw6lqjn5bjogsqxeqcswoqedcatdvphhts4frd7mb4jn7x4" test := testUtils.TestCase{ Description: "Test schema update, add field with update after schema update, commits query", diff --git a/tests/integration/schema/updates/add/field/kind/foreign_object_array_test.go b/tests/integration/schema/updates/add/field/kind/foreign_object_array_test.go index b0ee08bb80..8e1b97b3b7 100644 --- a/tests/integration/schema/updates/add/field/kind/foreign_object_array_test.go +++ b/tests/integration/schema/updates/add/field/kind/foreign_object_array_test.go @@ -65,30 +65,6 @@ func TestSchemaUpdatesAddFieldKindForeignObjectArray_InvalidSchemaJson(t *testin testUtils.ExecuteTestCase(t, test) } -func TestSchemaUpdatesAddFieldKindForeignObjectArray_MissingRelationType(t *testing.T) { - test := testUtils.TestCase{ - Description: "Test schema update, add field with kind foreign object (17), missing relation type", - Actions: []any{ - testUtils.SchemaUpdate{ - Schema: ` - type Users { - name: String - } - `, - }, - testUtils.SchemaPatch{ - Patch: ` - [ - { "op": "add", "path": "/Users/Fields/-", "value": {"Name": "foo", "Kind": 17, "Schema": "Users"} } - ] - `, - ExpectedError: "invalid RelationType. Field: foo, Expected: 10, Actual: 0", - }, - }, - } - testUtils.ExecuteTestCase(t, test) -} - func TestSchemaUpdatesAddFieldKindForeignObjectArray_MissingRelationName(t *testing.T) { test := testUtils.TestCase{ Description: "Test schema update, add field with kind foreign object array (17), missing relation name", @@ -104,7 +80,7 @@ func TestSchemaUpdatesAddFieldKindForeignObjectArray_MissingRelationName(t *test Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 17, "RelationType": 10, "Schema": "Users" + "Name": "foo", "Kind": 17, "Schema": "Users" }} ] `, @@ -130,7 +106,7 @@ func TestSchemaUpdatesAddFieldKindForeignObjectArray_IDFieldMissingKind(t *testi Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 137, "Schema": "Users", "RelationName": "foo" + "Name": "foo", "Kind": 16, "IsPrimaryRelation": true, "Schema": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": {"Name": "foo_id"} } ] @@ -157,7 +133,7 @@ func TestSchemaUpdatesAddFieldKindForeignObjectArray_IDFieldInvalidKind(t *testi Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 137, "Schema": "Users", "RelationName": "foo" + "Name": "foo", "Kind": 16, "IsPrimaryRelation": true, "Schema": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": {"Name": "foo_id", "Kind": 2} } ] @@ -169,60 +145,6 @@ func TestSchemaUpdatesAddFieldKindForeignObjectArray_IDFieldInvalidKind(t *testi testUtils.ExecuteTestCase(t, test) } -func TestSchemaUpdatesAddFieldKindForeignObjectArray_IDFieldMissingRelationType(t *testing.T) { - test := testUtils.TestCase{ - Description: "Test schema update, add field with kind foreign object array (17), id field missing relation type", - Actions: []any{ - testUtils.SchemaUpdate{ - Schema: ` - type Users { - name: String - } - `, - }, - testUtils.SchemaPatch{ - Patch: ` - [ - { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 137, "Schema": "Users", "RelationName": "foo" - }}, - { "op": "add", "path": "/Users/Fields/-", "value": {"Name": "foo_id", "Kind": 1} } - ] - `, - ExpectedError: "invalid RelationType. Field: foo_id, Expected: 64, Actual: 0", - }, - }, - } - testUtils.ExecuteTestCase(t, test) -} - -func TestSchemaUpdatesAddFieldKindForeignObjectArray_IDFieldInvalidRelationType(t *testing.T) { - test := testUtils.TestCase{ - Description: "Test schema update, add field with kind foreign object array (17), id field invalid RelationType", - Actions: []any{ - testUtils.SchemaUpdate{ - Schema: ` - type Users { - name: String - } - `, - }, - testUtils.SchemaPatch{ - Patch: ` - [ - { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 137, "Schema": "Users", "RelationName": "foo" - }}, - { "op": "add", "path": "/Users/Fields/-", "value": {"Name": "foo_id", "Kind": 1, "RelationType": 4} } - ] - `, - ExpectedError: "invalid RelationType. Field: foo_id, Expected: 64, Actual: 4", - }, - }, - } - testUtils.ExecuteTestCase(t, test) -} - func TestSchemaUpdatesAddFieldKindForeignObjectArray_IDFieldMissingRelationName(t *testing.T) { test := testUtils.TestCase{ Description: "Test schema update, add field with kind foreign object array (17), id field missing relation name", @@ -238,9 +160,9 @@ func TestSchemaUpdatesAddFieldKindForeignObjectArray_IDFieldMissingRelationName( Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 137, "Schema": "Users", "RelationName": "foo" + "Name": "foo", "Kind": 16, "IsPrimaryRelation": true, "Schema": "Users", "RelationName": "foo" }}, - { "op": "add", "path": "/Users/Fields/-", "value": {"Name": "foo_id", "Kind": 1, "RelationType": 64} } + { "op": "add", "path": "/Users/Fields/-", "value": {"Name": "foo_id", "Kind": 1} } ] `, ExpectedError: "missing relation name. Field: foo_id", @@ -265,10 +187,10 @@ func TestSchemaUpdatesAddFieldKindForeignObjectArray_OnlyHalfRelationDefined(t * Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 137, "Schema": "Users", "RelationName": "foo" + "Name": "foo", "Kind": 16, "IsPrimaryRelation": true, "Schema": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foo_id", "Kind": 1, "RelationName": "foo" }} ] `, @@ -294,13 +216,13 @@ func TestSchemaUpdatesAddFieldKindForeignObjectArray_NoPrimaryDefined(t *testing Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 9, "Schema": "Users", "RelationName": "foo" + "Name": "foo", "Kind": 16, "Schema": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foo_id", "Kind": 1, "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": 17, "RelationType": 10, "Schema": "Users", "RelationName": "foo" + "Name": "foobar", "Kind": 17, "Schema": "Users", "RelationName": "foo" }} ] `, @@ -326,13 +248,13 @@ func TestSchemaUpdatesAddFieldKindForeignObjectArray_PrimaryDefinedOnManySide(t Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 9, "Schema": "Users", "RelationName": "foo" + "Name": "foo", "Kind": 16, "Schema": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foo_id", "Kind": 1, "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": 17, "RelationType": 138, "Schema": "Users", "RelationName": "foo" + "Name": "foobar", "Kind": 17, "IsPrimaryRelation": true, "Schema": "Users", "RelationName": "foo" }} ] `, @@ -343,102 +265,6 @@ func TestSchemaUpdatesAddFieldKindForeignObjectArray_PrimaryDefinedOnManySide(t testUtils.ExecuteTestCase(t, test) } -func TestSchemaUpdatesAddFieldKindForeignObjectArray_RelatedKindMismatch(t *testing.T) { - test := testUtils.TestCase{ - Description: "Test schema update, add field with kind foreign object array (17), related kind mismatch", - Actions: []any{ - testUtils.SchemaUpdate{ - Schema: ` - type Users { - name: String - } - `, - }, - testUtils.SchemaPatch{ - Patch: ` - [ - { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 137, "Schema": "Users", "RelationName": "foo" - }}, - { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" - }}, - { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": 16, "RelationType": 10, "Schema": "Users", "RelationName": "foo" - }} - ] - `, - ExpectedError: "invalid Kind of the related field. RelationName: foo, Expected: 17, Actual: 16", - }, - }, - } - testUtils.ExecuteTestCase(t, test) -} - -func TestSchemaUpdatesAddFieldKindForeignObjectArray_RelatedKindAndRelationTypeMismatch(t *testing.T) { - test := testUtils.TestCase{ - Description: "Test schema update, add field with kind foreign object array (17), related kind mismatch", - Actions: []any{ - testUtils.SchemaUpdate{ - Schema: ` - type Users { - name: String - } - `, - }, - testUtils.SchemaPatch{ - Patch: ` - [ - { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 137, "Schema": "Users", "RelationName": "foo" - }}, - { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" - }}, - { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": 16, "RelationType": 9, "Schema": "Users", "RelationName": "foo" - }} - ] - `, - ExpectedError: "invalid Kind of the related field. RelationName: foo, Expected: 17, Actual: 16", - }, - }, - } - testUtils.ExecuteTestCase(t, test) -} - -func TestSchemaUpdatesAddFieldKindForeignObjectArray_RelatedRelationTypeMismatch(t *testing.T) { - test := testUtils.TestCase{ - Description: "Test schema update, add field with kind foreign object array (17), related relation type mismatch", - Actions: []any{ - testUtils.SchemaUpdate{ - Schema: ` - type Users { - name: String - } - `, - }, - testUtils.SchemaPatch{ - Patch: ` - [ - { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 137, "Schema": "Users", "RelationName": "foo" - }}, - { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" - }}, - { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": 16, "RelationType": 5, "Schema": "Users", "RelationName": "foo" - }} - ] - `, - ExpectedError: "invalid Kind of the related field. RelationName: foo, Expected: 17, Actual: 16", - }, - }, - } - testUtils.ExecuteTestCase(t, test) -} - func TestSchemaUpdatesAddFieldKindForeignObjectArray_Succeeds(t *testing.T) { key1 := "bae-decf6467-4c7c-50d7-b09d-0a7097ef6bad" @@ -456,13 +282,13 @@ func TestSchemaUpdatesAddFieldKindForeignObjectArray_Succeeds(t *testing.T) { Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 137, "Schema": "Users", "RelationName": "foo" + "Name": "foo", "Kind": 16, "IsPrimaryRelation": true, "Schema": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foo_id", "Kind": 1, "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": 17, "RelationType": 10, "Schema": "Users", "RelationName": "foo" + "Name": "foobar", "Kind": 17, "Schema": "Users", "RelationName": "foo" }} ] `, @@ -552,13 +378,13 @@ func TestSchemaUpdatesAddFieldKindForeignObjectArray_SinglePrimaryObjectKindSubs Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": "Users", "RelationType": 137, "Schema": "Users", "RelationName": "foo" + "Name": "foo", "Kind": "Users", "IsPrimaryRelation": true, "Schema": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foo_id", "Kind": 1, "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": 17, "RelationType": 10, "Schema": "Users", "RelationName": "foo" + "Name": "foobar", "Kind": 17, "Schema": "Users", "RelationName": "foo" }} ] `, @@ -631,13 +457,13 @@ func TestSchemaUpdatesAddFieldKindForeignObjectArray_SingleSecondaryObjectKindSu Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 137, "Schema": "Users", "RelationName": "foo" + "Name": "foo", "Kind": 16, "IsPrimaryRelation": true, "Schema": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foo_id", "Kind": 1, "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": "[Users]", "RelationType": 10, "Schema": "Users", "RelationName": "foo" + "Name": "foobar", "Kind": "[Users]", "Schema": "Users", "RelationName": "foo" }} ] `, @@ -710,13 +536,13 @@ func TestSchemaUpdatesAddFieldKindForeignObjectArray_ObjectKindSubstitution(t *t Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": "Users", "RelationType": 137, "Schema": "Users", "RelationName": "foo" + "Name": "foo", "Kind": "Users", "IsPrimaryRelation": true, "Schema": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foo_id", "Kind": 1, "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": "[Users]", "RelationType": 10, "Schema": "Users", "RelationName": "foo" + "Name": "foobar", "Kind": "[Users]", "Schema": "Users", "RelationName": "foo" }} ] `, @@ -789,13 +615,13 @@ func TestSchemaUpdatesAddFieldKindForeignObjectArray_ObjectKindSubstitutionWithA Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": "Users", "RelationType": 137, "RelationName": "foo" + "Name": "foo", "Kind": "Users", "IsPrimaryRelation": true, "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foo_id", "Kind": 1, "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": "[Users]", "RelationType": 10, "RelationName": "foo" + "Name": "foobar", "Kind": "[Users]", "RelationName": "foo" }} ] `, @@ -873,13 +699,13 @@ func TestSchemaUpdatesAddFieldKindForeignObjectArray_PrimaryObjectKindAndSchemaM Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": "Users", "RelationType": 137, "Schema": "Dog", "RelationName": "foo" + "Name": "foo", "Kind": "Users", "IsPrimaryRelation": true, "Schema": "Dog", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foo_id", "Kind": 1, "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": "[Users]", "RelationType": 10, "Schema": "Users", "RelationName": "foo" + "Name": "foobar", "Kind": "[Users]", "Schema": "Users", "RelationName": "foo" }} ] `, @@ -912,13 +738,13 @@ func TestSchemaUpdatesAddFieldKindForeignObjectArray_SecondaryObjectKindAndSchem Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": "Users", "RelationType": 137, "Schema": "Users", "RelationName": "foo" + "Name": "foo", "Kind": "Users", "IsPrimaryRelation": true, "Schema": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foo_id", "Kind": 1, "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": "[Users]", "RelationType": 10, "Schema": "Dog", "RelationName": "foo" + "Name": "foobar", "Kind": "[Users]", "Schema": "Dog", "RelationName": "foo" }} ] `, @@ -946,10 +772,10 @@ func TestSchemaUpdatesAddFieldKindForeignObjectArray_MissingPrimaryIDField(t *te Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": "Users", "RelationType": 137, "RelationName": "foo" + "Name": "foo", "Kind": "Users", "IsPrimaryRelation": true, "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": "[Users]", "RelationType": 10, "RelationName": "foo" + "Name": "foobar", "Kind": "[Users]", "RelationName": "foo" }} ] `, @@ -1023,10 +849,10 @@ func TestSchemaUpdatesAddFieldKindForeignObjectArray_MissingPrimaryIDField_DoesN Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": "Users", "RelationType": 137, "RelationName": "foo" + "Name": "foo", "Kind": "Users", "IsPrimaryRelation": true, "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": "[Users]", "RelationType": 10, "RelationName": "foo" + "Name": "foobar", "Kind": "[Users]", "RelationName": "foo" }} ] `, diff --git a/tests/integration/schema/updates/add/field/kind/foreign_object_test.go b/tests/integration/schema/updates/add/field/kind/foreign_object_test.go index dc724d5af7..feb64c3eeb 100644 --- a/tests/integration/schema/updates/add/field/kind/foreign_object_test.go +++ b/tests/integration/schema/updates/add/field/kind/foreign_object_test.go @@ -65,30 +65,6 @@ func TestSchemaUpdatesAddFieldKindForeignObject_InvalidSchemaJson(t *testing.T) testUtils.ExecuteTestCase(t, test) } -func TestSchemaUpdatesAddFieldKindForeignObject_MissingRelationType(t *testing.T) { - test := testUtils.TestCase{ - Description: "Test schema update, add field with kind foreign object (16), missing relation type", - Actions: []any{ - testUtils.SchemaUpdate{ - Schema: ` - type Users { - name: String - } - `, - }, - testUtils.SchemaPatch{ - Patch: ` - [ - { "op": "add", "path": "/Users/Fields/-", "value": {"Name": "foo", "Kind": 16, "Schema": "Users"} } - ] - `, - ExpectedError: "invalid RelationType. Field: foo, Expected: 1 and 4 or 8, with optionally 128, Actual: 0", - }, - }, - } - testUtils.ExecuteTestCase(t, test) -} - func TestSchemaUpdatesAddFieldKindForeignObject_UnknownSchema(t *testing.T) { test := testUtils.TestCase{ Description: "Test schema update, add field with kind foreign object (16), unknown schema", @@ -104,7 +80,7 @@ func TestSchemaUpdatesAddFieldKindForeignObject_UnknownSchema(t *testing.T) { Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 5, "Schema": "Unknown" + "Name": "foo", "Kind": 16, "Schema": "Unknown" }} ] `, @@ -130,7 +106,7 @@ func TestSchemaUpdatesAddFieldKindForeignObject_MissingRelationName(t *testing.T Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 5, "Schema": "Users" + "Name": "foo", "Kind": 16, "Schema": "Users" }} ] `, @@ -156,7 +132,7 @@ func TestSchemaUpdatesAddFieldKindForeignObject_IDFieldMissingKind(t *testing.T) Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 133, "Schema": "Users", "RelationName": "foo" + "Name": "foo", "Kind": 16,"IsPrimaryRelation": true, "Schema": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": {"Name": "foo_id"} } ] @@ -183,7 +159,7 @@ func TestSchemaUpdatesAddFieldKindForeignObject_IDFieldInvalidKind(t *testing.T) Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 133, "Schema": "Users", "RelationName": "foo" + "Name": "foo", "Kind": 16, "IsPrimaryRelation": true, "Schema": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": {"Name": "foo_id", "Kind": 2} } ] @@ -195,60 +171,6 @@ func TestSchemaUpdatesAddFieldKindForeignObject_IDFieldInvalidKind(t *testing.T) testUtils.ExecuteTestCase(t, test) } -func TestSchemaUpdatesAddFieldKindForeignObject_IDFieldMissingRelationType(t *testing.T) { - test := testUtils.TestCase{ - Description: "Test schema update, add field with kind foreign object (16), id field missing relation type", - Actions: []any{ - testUtils.SchemaUpdate{ - Schema: ` - type Users { - name: String - } - `, - }, - testUtils.SchemaPatch{ - Patch: ` - [ - { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 133, "Schema": "Users", "RelationName": "foo" - }}, - { "op": "add", "path": "/Users/Fields/-", "value": {"Name": "foo_id", "Kind": 1} } - ] - `, - ExpectedError: "invalid RelationType. Field: foo_id, Expected: 64, Actual: 0", - }, - }, - } - testUtils.ExecuteTestCase(t, test) -} - -func TestSchemaUpdatesAddFieldKindForeignObject_IDFieldInvalidRelationType(t *testing.T) { - test := testUtils.TestCase{ - Description: "Test schema update, add field with kind foreign object (16), id field invalid RelationType", - Actions: []any{ - testUtils.SchemaUpdate{ - Schema: ` - type Users { - name: String - } - `, - }, - testUtils.SchemaPatch{ - Patch: ` - [ - { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 133, "Schema": "Users", "RelationName": "foo" - }}, - { "op": "add", "path": "/Users/Fields/-", "value": {"Name": "foo_id", "Kind": 1, "RelationType": 4} } - ] - `, - ExpectedError: "invalid RelationType. Field: foo_id, Expected: 64, Actual: 4", - }, - }, - } - testUtils.ExecuteTestCase(t, test) -} - func TestSchemaUpdatesAddFieldKindForeignObject_IDFieldMissingRelationName(t *testing.T) { test := testUtils.TestCase{ Description: "Test schema update, add field with kind foreign object (16), id field missing relation name", @@ -264,9 +186,9 @@ func TestSchemaUpdatesAddFieldKindForeignObject_IDFieldMissingRelationName(t *te Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 133, "Schema": "Users", "RelationName": "foo" + "Name": "foo", "Kind": 16, "IsPrimaryRelation": true, "Schema": "Users", "RelationName": "foo" }}, - { "op": "add", "path": "/Users/Fields/-", "value": {"Name": "foo_id", "Kind": 1, "RelationType": 64} } + { "op": "add", "path": "/Users/Fields/-", "value": {"Name": "foo_id", "Kind": 1} } ] `, ExpectedError: "missing relation name. Field: foo_id", @@ -291,10 +213,10 @@ func TestSchemaUpdatesAddFieldKindForeignObject_OnlyHalfRelationDefined(t *testi Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 133, "Schema": "Users", "RelationName": "foo" + "Name": "foo", "Kind": 16, "IsPrimaryRelation": true, "Schema": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foo_id", "Kind": 1, "RelationName": "foo" }} ] `, @@ -320,13 +242,13 @@ func TestSchemaUpdatesAddFieldKindForeignObject_NoPrimaryDefined(t *testing.T) { Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 5, "Schema": "Users", "RelationName": "foo" + "Name": "foo", "Kind": 16, "Schema": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foo_id", "Kind": 1, "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": 16, "RelationType": 5, "Schema": "Users", "RelationName": "foo" + "Name": "foobar", "Kind": 16, "Schema": "Users", "RelationName": "foo" }} ] `, @@ -352,16 +274,16 @@ func TestSchemaUpdatesAddFieldKindForeignObject_BothSidesPrimary(t *testing.T) { Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 133, "Schema": "Users", "RelationName": "foo" + "Name": "foo", "Kind": 16, "IsPrimaryRelation": true, "Schema": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foo_id", "Kind": 1, "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": 16, "RelationType": 133, "Schema": "Users", "RelationName": "foo" + "Name": "foobar", "Kind": 16, "IsPrimaryRelation": true, "Schema": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar_id", "Kind": 1, "RelationType": 64, "Schema": "Users", "RelationName": "foo" + "Name": "foobar_id", "Kind": 1, "Schema": "Users", "RelationName": "foo" }} ] `, @@ -372,70 +294,6 @@ func TestSchemaUpdatesAddFieldKindForeignObject_BothSidesPrimary(t *testing.T) { testUtils.ExecuteTestCase(t, test) } -func TestSchemaUpdatesAddFieldKindForeignObject_RelatedKindMismatch(t *testing.T) { - test := testUtils.TestCase{ - Description: "Test schema update, add field with kind foreign object (16), related kind mismatch", - Actions: []any{ - testUtils.SchemaUpdate{ - Schema: ` - type Users { - name: String - } - `, - }, - testUtils.SchemaPatch{ - Patch: ` - [ - { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 133, "Schema": "Users", "RelationName": "foo" - }}, - { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" - }}, - { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": 17, "RelationType": 5, "Schema": "Users", "RelationName": "foo" - }} - ] - `, - ExpectedError: "invalid Kind of the related field. RelationName: foo, Expected: 16, Actual: 17", - }, - }, - } - testUtils.ExecuteTestCase(t, test) -} - -func TestSchemaUpdatesAddFieldKindForeignObject_RelatedRelationTypeMismatch(t *testing.T) { - test := testUtils.TestCase{ - Description: "Test schema update, add field with kind foreign object (16), related relation type mismatch", - Actions: []any{ - testUtils.SchemaUpdate{ - Schema: ` - type Users { - name: String - } - `, - }, - testUtils.SchemaPatch{ - Patch: ` - [ - { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 133, "Schema": "Users", "RelationName": "foo" - }}, - { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" - }}, - { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": 16, "RelationType": 9, "Schema": "Users", "RelationName": "foo" - }} - ] - `, - ExpectedError: "invalid RelationType of the related field. RelationName: foo, Expected: 4, Actual: 9", - }, - }, - } - testUtils.ExecuteTestCase(t, test) -} - func TestSchemaUpdatesAddFieldKindForeignObject_Succeeds(t *testing.T) { key1 := "bae-decf6467-4c7c-50d7-b09d-0a7097ef6bad" @@ -453,16 +311,16 @@ func TestSchemaUpdatesAddFieldKindForeignObject_Succeeds(t *testing.T) { Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 133, "Schema": "Users", "RelationName": "foo" + "Name": "foo", "Kind": 16, "IsPrimaryRelation": true, "Schema": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foo_id", "Kind": 1, "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": 16, "RelationType": 5, "Schema": "Users", "RelationName": "foo" + "Name": "foobar", "Kind": 16, "Schema": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foobar_id", "Kind": 1, "RelationName": "foo" }} ] `, @@ -550,16 +408,16 @@ func TestSchemaUpdatesAddFieldKindForeignObject_SinglePrimaryObjectKindSubstitut Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": "Users", "RelationType": 133, "Schema": "Users", "RelationName": "foo" + "Name": "foo", "Kind": "Users", "IsPrimaryRelation": true, "Schema": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foo_id", "Kind": 1, "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": 16, "RelationType": 5, "Schema": "Users", "RelationName": "foo" + "Name": "foobar", "Kind": 16, "Schema": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foobar_id", "Kind": 1, "RelationName": "foo" }} ] `, @@ -630,16 +488,16 @@ func TestSchemaUpdatesAddFieldKindForeignObject_SingleSecondaryObjectKindSubstit Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": 16, "RelationType": 133, "Schema": "Users", "RelationName": "foo" + "Name": "foo", "Kind": 16, "IsPrimaryRelation": true, "Schema": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foo_id", "Kind": 1, "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": "Users", "RelationType": 5, "Schema": "Users", "RelationName": "foo" + "Name": "foobar", "Kind": "Users", "Schema": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foobar_id", "Kind": 1, "RelationName": "foo" }} ] `, @@ -710,16 +568,16 @@ func TestSchemaUpdatesAddFieldKindForeignObject_ObjectKindSubstitution(t *testin Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": "Users", "RelationType": 133, "Schema": "Users", "RelationName": "foo" + "Name": "foo", "Kind": "Users", "IsPrimaryRelation": true, "Schema": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foo_id", "Kind": 1, "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": "Users", "RelationType": 5, "Schema": "Users", "RelationName": "foo" + "Name": "foobar", "Kind": "Users", "Schema": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foobar_id", "Kind": 1, "RelationName": "foo" }} ] `, @@ -790,16 +648,16 @@ func TestSchemaUpdatesAddFieldKindForeignObject_ObjectKindSubstitutionWithAutoSc Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": "Users", "RelationType": 133, "RelationName": "foo" + "Name": "foo", "Kind": "Users", "IsPrimaryRelation": true, "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foo_id", "Kind": 1, "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": "Users", "RelationType": 5, "RelationName": "foo" + "Name": "foobar", "Kind": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foobar_id", "Kind": 1, "RelationName": "foo" }} ] `, @@ -875,16 +733,16 @@ func TestSchemaUpdatesAddFieldKindForeignObject_ObjectKindAndSchemaMismatch(t *t Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": "Users", "RelationType": 133, "Schema": "Dog", "RelationName": "foo" + "Name": "foo", "Kind": "Users", "IsPrimaryRelation": true, "Schema": "Dog", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foo_id", "Kind": 1, "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": "Users", "RelationType": 5, "RelationName": "foo" + "Name": "foobar", "Kind": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foobar_id", "Kind": 1, "RelationName": "foo" }} ] `, @@ -912,13 +770,13 @@ func TestSchemaUpdatesAddFieldKindForeignObject_MissingPrimaryIDField(t *testing Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": "Users", "RelationType": 133, "RelationName": "foo" + "Name": "foo", "Kind": "Users", "IsPrimaryRelation": true, "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": "Users", "RelationType": 5, "RelationName": "foo" + "Name": "foobar", "Kind": "Users", "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foobar_id", "Kind": 1, "RelationName": "foo" }} ] `, @@ -990,13 +848,13 @@ func TestSchemaUpdatesAddFieldKindForeignObject_MissingSecondaryIDField(t *testi Patch: ` [ { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo", "Kind": "Users", "RelationType": 133, "RelationName": "foo" + "Name": "foo", "Kind": "Users", "IsPrimaryRelation": true, "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foo_id", "Kind": 1, "RelationType": 64, "RelationName": "foo" + "Name": "foo_id", "Kind": 1, "RelationName": "foo" }}, { "op": "add", "path": "/Users/Fields/-", "value": { - "Name": "foobar", "Kind": "Users", "RelationType": 5, "RelationName": "foo" + "Name": "foobar", "Kind": "Users", "RelationName": "foo" }} ] `, diff --git a/tests/integration/schema/updates/add/field/simple_test.go b/tests/integration/schema/updates/add/field/simple_test.go index 63e6f5f9f6..88c7fc2865 100644 --- a/tests/integration/schema/updates/add/field/simple_test.go +++ b/tests/integration/schema/updates/add/field/simple_test.go @@ -20,8 +20,8 @@ import ( ) func TestSchemaUpdatesAddFieldSimple(t *testing.T) { - schemaVersion1ID := "bafkreig3zt63qt7bkji47etyu2sqtzroa3tcfdxgwqc3ka2ijy63refq3a" - schemaVersion2ID := "bafkreiclwd4nrvczrzy7aj52olojyzvgm4ht6jpktwpxuqej5wk3ocxpqi" + schemaVersion1ID := "bafkreibjb4h5nudsei7cq2kkontjinmjpbqls2tmowqp5nxougu4tuus4i" + schemaVersion2ID := "bafkreibzozorw6lqjn5bjogsqxeqcswoqedcatdvphhts4frd7mb4jn7x4" test := testUtils.TestCase{ Description: "Test schema update, add field", @@ -117,8 +117,8 @@ func TestSchemaUpdates_AddFieldSimpleDoNotSetDefault_Errors(t *testing.T) { } func TestSchemaUpdates_AddFieldSimpleDoNotSetDefault_VersionIsQueryable(t *testing.T) { - schemaVersion1ID := "bafkreig3zt63qt7bkji47etyu2sqtzroa3tcfdxgwqc3ka2ijy63refq3a" - schemaVersion2ID := "bafkreiclwd4nrvczrzy7aj52olojyzvgm4ht6jpktwpxuqej5wk3ocxpqi" + schemaVersion1ID := "bafkreibjb4h5nudsei7cq2kkontjinmjpbqls2tmowqp5nxougu4tuus4i" + schemaVersion2ID := "bafkreibzozorw6lqjn5bjogsqxeqcswoqedcatdvphhts4frd7mb4jn7x4" test := testUtils.TestCase{ Description: "Test schema update, add field", diff --git a/tests/integration/schema/updates/move/simple_test.go b/tests/integration/schema/updates/move/simple_test.go index e16226c1cf..527d3def52 100644 --- a/tests/integration/schema/updates/move/simple_test.go +++ b/tests/integration/schema/updates/move/simple_test.go @@ -17,7 +17,7 @@ import ( ) func TestSchemaUpdatesMoveCollectionDoesNothing(t *testing.T) { - schemaVersionID := "bafkreig3zt63qt7bkji47etyu2sqtzroa3tcfdxgwqc3ka2ijy63refq3a" + schemaVersionID := "bafkreibjb4h5nudsei7cq2kkontjinmjpbqls2tmowqp5nxougu4tuus4i" test := testUtils.TestCase{ Description: "Test schema update, move collection", diff --git a/tests/integration/schema/updates/remove/fields/simple_test.go b/tests/integration/schema/updates/remove/fields/simple_test.go index 515a8736e5..c46515a474 100644 --- a/tests/integration/schema/updates/remove/fields/simple_test.go +++ b/tests/integration/schema/updates/remove/fields/simple_test.go @@ -178,7 +178,7 @@ func TestSchemaUpdatesRemoveFieldSchemaErrors(t *testing.T) { } type Book { name: String - author: [Author] + author: Author } `, }, @@ -207,7 +207,7 @@ func TestSchemaUpdatesRemoveFieldRelationNameErrors(t *testing.T) { } type Book { name: String - author: [Author] + author: Author } `, }, @@ -223,32 +223,3 @@ func TestSchemaUpdatesRemoveFieldRelationNameErrors(t *testing.T) { } testUtils.ExecuteTestCase(t, test) } - -func TestSchemaUpdatesRemoveFieldRelationTypeErrors(t *testing.T) { - test := testUtils.TestCase{ - Description: "Test schema update, remove field RelationType", - Actions: []any{ - testUtils.SchemaUpdate{ - Schema: ` - type Author { - name: String - book: [Book] - } - type Book { - name: String - author: [Author] - } - `, - }, - testUtils.SchemaPatch{ - Patch: ` - [ - { "op": "remove", "path": "/Author/Fields/1/RelationType" } - ] - `, - ExpectedError: "mutating an existing field is not supported. ID: 1, ProposedName: book", - }, - }, - } - testUtils.ExecuteTestCase(t, test) -} diff --git a/tests/integration/schema/updates/test/field/simple_test.go b/tests/integration/schema/updates/test/field/simple_test.go index 414a472149..5b1428d20d 100644 --- a/tests/integration/schema/updates/test/field/simple_test.go +++ b/tests/integration/schema/updates/test/field/simple_test.go @@ -102,7 +102,7 @@ func TestSchemaUpdatesTestFieldPasses(t *testing.T) { Patch: ` [ { "op": "test", "path": "/Users/Fields/1", "value": { - "ID":1, "Name": "name", "Kind": 11, "Schema":"","RelationName":"","Typ":1,"RelationType":0 + "ID":1, "Name": "name", "Kind": 11, "Schema":"", "IsPrimaryRelation":false, "RelationName":"", "Typ":1 } } ] `, @@ -127,7 +127,7 @@ func TestSchemaUpdatesTestFieldPasses_UsingFieldNameAsIndex(t *testing.T) { Patch: ` [ { "op": "test", "path": "/Users/Fields/name", "value": { - "ID":1, "Kind": 11, "Schema":"","RelationName":"","Typ":1,"RelationType":0 + "ID":1, "Kind": 11, "Schema":"", "IsPrimaryRelation":false, "RelationName":"", "Typ":1 } } ] `, diff --git a/tests/integration/schema/with_update_set_default_test.go b/tests/integration/schema/with_update_set_default_test.go index 602e6d48d6..d768830a5e 100644 --- a/tests/integration/schema/with_update_set_default_test.go +++ b/tests/integration/schema/with_update_set_default_test.go @@ -92,7 +92,7 @@ func TestSchema_WithUpdateAndSetDefaultVersionToOriginal_NewFieldIsNotQueriable( SetAsDefaultVersion: immutable.Some(false), }, testUtils.SetDefaultSchemaVersion{ - SchemaVersionID: "bafkreig3zt63qt7bkji47etyu2sqtzroa3tcfdxgwqc3ka2ijy63refq3a", + SchemaVersionID: "bafkreibjb4h5nudsei7cq2kkontjinmjpbqls2tmowqp5nxougu4tuus4i", }, testUtils.Request{ Request: `query { @@ -129,7 +129,7 @@ func TestSchema_WithUpdateAndSetDefaultVersionToNew_AllowsQueryingOfNewField(t * SetAsDefaultVersion: immutable.Some(false), }, testUtils.SetDefaultSchemaVersion{ - SchemaVersionID: "bafkreiclwd4nrvczrzy7aj52olojyzvgm4ht6jpktwpxuqej5wk3ocxpqi", + SchemaVersionID: "bafkreibzozorw6lqjn5bjogsqxeqcswoqedcatdvphhts4frd7mb4jn7x4", }, testUtils.Request{ Request: `query { diff --git a/tests/predefined/gen_predefined.go b/tests/predefined/gen_predefined.go index 0a203fe2ed..256b6b383d 100644 --- a/tests/predefined/gen_predefined.go +++ b/tests/predefined/gen_predefined.go @@ -134,7 +134,7 @@ func (this *docGenerator) generatePrimary( for _, secDocField := range secType.Schema.Fields { if secDocField.IsRelation() { if secDocMapField, hasField := secDocMap[secDocField.Name]; hasField { - if secDocField.IsPrimaryRelation() { + if secDocField.IsPrimaryRelation { primType := this.types[secDocField.Schema] primDocMap, subResult, err := this.generatePrimary( secDocMap[secDocField.Name].(map[string]any), &primType) @@ -199,7 +199,7 @@ func (this *docGenerator) generateSecondaryDocs( for _, field := range primaryType.Schema.Fields { if field.IsRelation() { if _, hasProp := primaryDocMap[field.Name]; hasProp { - if !field.IsPrimaryRelation() && + if !field.IsPrimaryRelation && (parentTypeName == "" || parentTypeName != field.Schema) { docs, err := this.generateSecondaryDocsForField( primaryDocMap, primaryType.Description.Name.Value(), &field, docID) @@ -225,7 +225,7 @@ func (this *docGenerator) generateSecondaryDocsForField( relTypeDef := this.types[relField.Schema] primaryPropName := "" for _, relDocField := range relTypeDef.Schema.Fields { - if relDocField.Schema == primaryTypeName && relDocField.IsPrimaryRelation() { + if relDocField.Schema == primaryTypeName && relDocField.IsPrimaryRelation { primaryPropName = relDocField.Name + request.RelatedObjectID switch relVal := primaryDoc[relField.Name].(type) { case []map[string]any: diff --git a/tests/predefined/gen_predefined_test.go b/tests/predefined/gen_predefined_test.go index ae68cf9804..951aa5f763 100644 --- a/tests/predefined/gen_predefined_test.go +++ b/tests/predefined/gen_predefined_test.go @@ -517,7 +517,6 @@ func TestGeneratePredefinedFromSchema_TwoPrimaryToOneRoot(t *testing.T) { // Name: "devices", // Kind: client.FieldKind_FOREIGN_OBJECT_ARRAY, // Schema: "Device", -// RelationType: client.Relation_Type_MANY | client.Relation_Type_ONEMANY, // }, // }, // }, @@ -538,9 +537,7 @@ func TestGeneratePredefinedFromSchema_TwoPrimaryToOneRoot(t *testing.T) { // Name: "owner", // Kind: client.FieldKind_FOREIGN_OBJECT, // Schema: "User", -// RelationType: client.Relation_Type_ONE | -// client.Relation_Type_ONEMANY | -// client.Relation_Type_Primary, +// IsPrimary: true, // }, // }, // },