Skip to content

Commit

Permalink
resolving post merge issues
Browse files Browse the repository at this point in the history
  • Loading branch information
fredcarle committed Jan 5, 2024
1 parent 95ee825 commit 6da093a
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 31 deletions.
2 changes: 1 addition & 1 deletion db/collection_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion tests/clients/cli/wrapper_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/gen/gen_auto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}`,
Expand Down Expand Up @@ -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
}
}`,
Expand Down Expand Up @@ -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
}
}`,
Expand Down Expand Up @@ -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
}
}`,
Expand Down
12 changes: 5 additions & 7 deletions tests/integration/query/one_to_many/with_cid_doc_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
34 changes: 17 additions & 17 deletions tests/predefined/gen_predefined_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6da093a

Please sign in to comment.