Skip to content

Commit

Permalink
Create document with actual docID not user provided value
Browse files Browse the repository at this point in the history
This is a bug I accidentally fixed (originally in another commit), we should probably have more tests that cover this, but I'm not interested in adding them in this PR.
  • Loading branch information
AndrewSisley committed Nov 20, 2024
1 parent 32dcb73 commit 2747b2d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
18 changes: 10 additions & 8 deletions internal/db/fetcher/versioned.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ type VersionedFetcher struct {
root datastore.Rootstore
store datastore.Txn

dsKey keys.DataStoreKey

queuedCids *list.List

acp immutable.Option[acp.ACP]
Expand Down Expand Up @@ -157,10 +155,6 @@ func (vf *VersionedFetcher) Start(ctx context.Context, spans ...core.Span) error
prefix := spans[0].Start.(keys.HeadstoreDocKey)

vf.ctx = ctx
vf.dsKey = keys.DataStoreKey{
CollectionRootID: vf.col.Description().RootID,
DocID: prefix.DocID,
}

if err := vf.seekTo(prefix.Cid); err != nil {
return NewErrFailedToSeek(prefix.Cid, err)
Expand Down Expand Up @@ -329,7 +323,11 @@ func (vf *VersionedFetcher) merge(c cid.Cid) error {
mcrdt = merklecrdt.NewMerkleCompositeDAG(
vf.store,
keys.NewCollectionSchemaVersionKey(block.Delta.GetSchemaVersionID(), vf.col.Description().RootID),
vf.dsKey.WithFieldID(core.COMPOSITE_NAMESPACE),
keys.DataStoreKey{
CollectionRootID: vf.col.Description().RootID,
DocID: string(block.Delta.GetDocID()),
FieldID: fmt.Sprint(core.COMPOSITE_NAMESPACE),
},
)
vf.mCRDTs[0] = mcrdt
}
Expand Down Expand Up @@ -358,7 +356,11 @@ func (vf *VersionedFetcher) merge(c cid.Cid) error {
keys.NewCollectionSchemaVersionKey(block.Delta.GetSchemaVersionID(), vf.col.Description().RootID),
field.Typ,
field.Kind,
vf.dsKey.WithFieldID(fmt.Sprint(field.ID)),
keys.DataStoreKey{
CollectionRootID: vf.col.Description().RootID,
DocID: string(block.Delta.GetDocID()),
FieldID: fmt.Sprint(field.ID),
},
field.Name,
)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/query/simple/with_cid_doc_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func TestCidAndDocIDQuery_ContainsPNCounterWithIntKind_NoError(t *testing.T) {
Request: `query {
Users (
cid: "bafyreihsqayh6zvmjrvmma3sjmrb4bkeiyy6l56nt6y2t2tm4xajkif3gu",
docID: "bae-d8cb53d4-ac5a-5c55-8306-64df633d400d"
docID: "bae-bc5464e4-26a6-5307-b516-aada0abeb089"
) {
name
points
Expand Down Expand Up @@ -389,7 +389,7 @@ func TestCidAndDocIDQuery_ContainsPNCounterWithFloatKind_NoError(t *testing.T) {
Request: `query {
Users (
cid: "bafyreigkdjnvkpqfjoqoke3aqc3b6ibb45xjuxx5djpk7c6tart2lw3dcm",
docID: "bae-d420ebcd-023a-5800-ae2e-8ea89442318e"
docID: "bae-2c7c40a7-92c1-5ed4-8a00-9e8595514945"
) {
name
points
Expand Down

0 comments on commit 2747b2d

Please sign in to comment.