Skip to content

Commit

Permalink
Remove unhelpful col.schemaID property
Browse files Browse the repository at this point in the history
Just get it from col.Schema instead of having to maintain the same prop in multiple places - this caused a bug briefly.
  • Loading branch information
AndrewSisley committed Oct 2, 2023
1 parent cb0699c commit 52c38b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
17 changes: 6 additions & 11 deletions db/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ type collection struct {

colID uint32

schemaID string

desc client.CollectionDescription
schema client.SchemaDescription

Expand Down Expand Up @@ -153,7 +151,6 @@ func (db *db) createCollection(
return nil, err
}
schemaID := cid.String()
col.schemaID = schemaID

// For new schemas the initial version id will match the schema id
schemaVersionID := schemaID
Expand Down Expand Up @@ -640,11 +637,10 @@ func (db *db) getCollectionByVersionID(
}

col := &collection{
db: db,
desc: desc,
schema: desc.Schema,
colID: desc.ID,
schemaID: desc.Schema.SchemaID,
db: db,
desc: desc,
schema: desc.Schema,
colID: desc.ID,
}

err = col.loadIndexes(ctx, txn)
Expand Down Expand Up @@ -816,7 +812,7 @@ func (c *collection) ID() uint32 {
}

func (c *collection) SchemaID() string {
return c.schemaID
return c.Schema().SchemaID
}

// WithTxn returns a new instance of the collection, with a transaction
Expand All @@ -828,7 +824,6 @@ func (c *collection) WithTxn(txn datastore.Txn) client.Collection {
desc: c.desc,
schema: c.schema,
colID: c.colID,
schemaID: c.schemaID,
indexes: c.indexes,
fetcherFactory: c.fetcherFactory,
}
Expand Down Expand Up @@ -1113,7 +1108,7 @@ func (c *collection) save(
events.Update{
DocKey: doc.Key().String(),
Cid: headNode.Cid(),
SchemaID: c.schemaID,
SchemaID: c.Schema().SchemaID,
Block: headNode,
Priority: priority,
},
Expand Down
2 changes: 1 addition & 1 deletion db/collection_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ func (c *collection) applyDelete(
events.Update{
DocKey: key.DocKey,
Cid: headNode.Cid(),
SchemaID: c.schemaID,
SchemaID: c.Schema().SchemaID,
Block: headNode,
Priority: priority,
},
Expand Down

0 comments on commit 52c38b1

Please sign in to comment.