From 6da093a34b6a5780e22ffd2b92a22b52f8610845 Mon Sep 17 00:00:00 2001 From: Fred Carle Date: Fri, 5 Jan 2024 15:09:38 +0100 Subject: [PATCH] resolving post merge issues --- db/collection_update.go | 2 +- tests/clients/cli/wrapper_collection.go | 2 +- tests/gen/gen_auto_test.go | 2 +- .../one_to_one_to_one/with_txn_test.go | 8 ++--- .../query/one_to_many/with_cid_doc_id_test.go | 12 +++---- tests/predefined/gen_predefined_test.go | 34 +++++++++---------- 6 files changed, 29 insertions(+), 31 deletions(-) diff --git a/db/collection_update.go b/db/collection_update.go index 0dfb371517..4c1895602b 100644 --- a/db/collection_update.go +++ b/db/collection_update.go @@ -358,7 +358,7 @@ func (c *collection) patchPrimaryDoc( } pc := c.db.newCollection(primaryCol.Description(), primarySchema) - err = pc.validateOneToOneLinkDoesntAlreadyExist(ctx, txn, primaryDockey.String(), primaryIDField, docKey) + err = pc.validateOneToOneLinkDoesntAlreadyExist(ctx, txn, primaryDocID.String(), primaryIDField, docID) if err != nil { return err } diff --git a/tests/clients/cli/wrapper_collection.go b/tests/clients/cli/wrapper_collection.go index 98eda67fd8..8295bad8d7 100644 --- a/tests/clients/cli/wrapper_collection.go +++ b/tests/clients/cli/wrapper_collection.go @@ -298,7 +298,7 @@ func (c *Collection) Get(ctx context.Context, docID client.DocID, showDeleted bo if err != nil { return nil, err } - doc := client.NewDocWithKey(key, c.Schema()) + doc := client.NewDocWithID(docID, c.Schema()) err = doc.SetWithJSON(data) if err != nil { return nil, err diff --git a/tests/gen/gen_auto_test.go b/tests/gen/gen_auto_test.go index 6e43a89958..f22859df0c 100644 --- a/tests/gen/gen_auto_test.go +++ b/tests/gen/gen_auto_test.go @@ -1353,7 +1353,7 @@ func TestAutoGenerate_IfColDefinitionsAreValid_ShouldGenerate(t *testing.T) { }, { Name: "owner_id", - Kind: client.FieldKind_DocKey, + Kind: client.FieldKind_DocID, RelationType: client.Relation_Type_INTERNAL_ID, }, }, diff --git a/tests/integration/mutation/delete/field_kinds/one_to_one_to_one/with_txn_test.go b/tests/integration/mutation/delete/field_kinds/one_to_one_to_one/with_txn_test.go index 2cb3ede8d1..4eed71eeb4 100644 --- a/tests/integration/mutation/delete/field_kinds/one_to_one_to_one/with_txn_test.go +++ b/tests/integration/mutation/delete/field_kinds/one_to_one_to_one/with_txn_test.go @@ -45,7 +45,7 @@ func TestTxnDeletionOfRelatedDocFromPrimarySideForwardDirection(t *testing.T) { // Delete a linked book that exists. TransactionID: immutable.Some(0), Request: `mutation { - delete_Book(id: "bae-37de3681-1856-5bc9-9fd6-1595647b7d96") { + delete_Book(docID: "bae-37de3681-1856-5bc9-9fd6-1595647b7d96") { _docID } }`, @@ -111,7 +111,7 @@ func TestTxnDeletionOfRelatedDocFromPrimarySideBackwardDirection(t *testing.T) { // Delete a linked book that exists. TransactionID: immutable.Some(0), Request: `mutation { - delete_Book(id: "bae-37de3681-1856-5bc9-9fd6-1595647b7d96") { + delete_Book(docID: "bae-37de3681-1856-5bc9-9fd6-1595647b7d96") { _docID } }`, @@ -171,7 +171,7 @@ func TestATxnCanReadARecordThatIsDeletedInANonCommitedTxnForwardDirection(t *tes // Delete a linked book that exists. TransactionID: immutable.Some(0), Request: `mutation { - delete_Book(id: "bae-37de3681-1856-5bc9-9fd6-1595647b7d96") { + delete_Book(docID: "bae-37de3681-1856-5bc9-9fd6-1595647b7d96") { _docID } }`, @@ -261,7 +261,7 @@ func TestATxnCanReadARecordThatIsDeletedInANonCommitedTxnBackwardDirection(t *te // Delete a linked book that exists in transaction 0. TransactionID: immutable.Some(0), Request: `mutation { - delete_Book(id: "bae-37de3681-1856-5bc9-9fd6-1595647b7d96") { + delete_Book(docID: "bae-37de3681-1856-5bc9-9fd6-1595647b7d96") { _docID } }`, 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 ca28e418dc..f0eb805487 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: "bafybeice3ytsbgioxatbiwr7qrdipcpfbaa6kquegahxrdb4o7ex2jqrei" + cid: "bafybeiddywe5odj47ljhyslzey3kbmw3yqdzsstqqjh3ge6cliy2unty64" 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: "bafybeice3ytsbgioxatbiwr7qrdipcpfbaa6kquegahxrdb4o7ex2jqrei", + cid: "bafybeiddywe5odj47ljhyslzey3kbmw3yqdzsstqqjh3ge6cliy2unty64", docID: "bae-b9b83269-1f28-5c3b-ae75-3fb4c00d559d" ) { name @@ -173,14 +173,12 @@ 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: "bafybeice3ytsbgioxatbiwr7qrdipcpfbaa6kquegahxrdb4o7ex2jqrei", + cid: "bafybeie2okvnf3w3767gspsnln5d6n54hvnmu65wjkadxciopwoi6gxqha", docID: "bae-b9b83269-1f28-5c3b-ae75-3fb4c00d559d" ) { name } - } - }`, - + }`, Docs: map[int][]string{ //books 0: { // bae-fd541c25-229e-5280-b44b-e5c2af3e374d @@ -227,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: "bafybeibnwnbpudfbrp3ly76bbqbraskrdfpr2dlym7o3ojdfkdmkvvh2yu", + cid: "bafybeie2okvnf3w3767gspsnln5d6n54hvnmu65wjkadxciopwoi6gxqha", docID: "bae-b9b83269-1f28-5c3b-ae75-3fb4c00d559d" ) { name diff --git a/tests/predefined/gen_predefined_test.go b/tests/predefined/gen_predefined_test.go index 512d06d826..ae68cf9804 100644 --- a/tests/predefined/gen_predefined_test.go +++ b/tests/predefined/gen_predefined_test.go @@ -416,15 +416,15 @@ func TestGeneratePredefinedFromSchema_TwoPrimaryToOneRoot(t *testing.T) { // colDefMap, err := parseSDL(schema) // require.NoError(t, err) -// johnDocKey := mustGetDocIDFromDocMap(map[string]any{"name": "John"}, colDefMap["User"].Schema) -// fredDocKey := mustGetDocIDFromDocMap(map[string]any{"name": "Fred"}, colDefMap["User"].Schema) +// johnDocID := mustGetDocIDFromDocMap(map[string]any{"name": "John"}, colDefMap["User"].Schema) +// fredDocID := mustGetDocIDFromDocMap(map[string]any{"name": "Fred"}, colDefMap["User"].Schema) // errorMsg := assertDocs(mustAddDocIDsToDocs([]map[string]any{ // {"name": "John"}, // {"name": "Fred"}, -// {"model": "iPhone", "owner_id": johnDocKey}, -// {"model": "PlayStation", "owner_id": johnDocKey}, -// {"model": "Surface", "owner_id": fredDocKey}, -// {"model": "Pixel", "owner_id": fredDocKey}, +// {"model": "iPhone", "owner_id": johnDocID}, +// {"model": "PlayStation", "owner_id": johnDocID}, +// {"model": "Surface", "owner_id": fredDocID}, +// {"model": "Pixel", "owner_id": fredDocID}, // }, col), docs) // if errorMsg != "" { // t.Error(errorMsg) @@ -474,23 +474,23 @@ func TestGeneratePredefinedFromSchema_TwoPrimaryToOneRoot(t *testing.T) { // colDefMap, err := parseSDL(schema) // require.NoError(t, err) -// johnDocKey := mustGetDocIDFromDocMap(map[string]any{"name": "John"}, colDefMap["User"].Schema) +// johnDocID := mustGetDocIDFromDocMap(map[string]any{"name": "John"}, colDefMap["User"].Schema) // errorMsg := assertDocs(mustAddDocIDsToDocs([]map[string]any{ // {"name": "John"}, -// {"model": "iPhone", "owner_id": johnDocKey}, -// {"model": "MacBook", "owner_id": johnDocKey}, +// {"model": "iPhone", "owner_id": johnDocID}, +// {"model": "MacBook", "owner_id": johnDocID}, // { // "CPU": "A13", // "device_id": mustGetDocIDFromDocMap(map[string]any{ // "model": "iPhone", -// "owner_id": johnDocKey, +// "owner_id": johnDocID, // }, colDefMap["Device"].Schema), // }, // { // "CPU": "M2", // "device_id": mustGetDocIDFromDocMap(map[string]any{ // "model": "MacBook", -// "owner_id": johnDocKey, +// "owner_id": johnDocID, // }, colDefMap["Device"].Schema), // }, // }), docs) @@ -567,15 +567,15 @@ func TestGeneratePredefinedFromSchema_TwoPrimaryToOneRoot(t *testing.T) { // }) // assert.NoError(t, err) -// johnDocKey := mustGetDocIDFromDocMap(map[string]any{"name": "John"}, defs[0].Schema) -// fredDocKey := mustGetDocIDFromDocMap(map[string]any{"name": "Fred"}, defs[0].Schema) +// johnDocID := mustGetDocIDFromDocMap(map[string]any{"name": "John"}, defs[0].Schema) +// fredDocID := mustGetDocIDFromDocMap(map[string]any{"name": "Fred"}, defs[0].Schema) // errorMsg := assertDocs(mustAddDocIDsToDocs([]map[string]any{ // {"name": "John"}, // {"name": "Fred"}, -// {"model": "iPhone", "owner_id": johnDocKey}, -// {"model": "PlayStation", "owner_id": johnDocKey}, -// {"model": "Surface", "owner_id": fredDocKey}, -// {"model": "Pixel", "owner_id": fredDocKey}, +// {"model": "iPhone", "owner_id": johnDocID}, +// {"model": "PlayStation", "owner_id": johnDocID}, +// {"model": "Surface", "owner_id": fredDocID}, +// {"model": "Pixel", "owner_id": fredDocID}, // }), docs) // if errorMsg != "" { // t.Error(errorMsg)