Skip to content

Commit

Permalink
Use schema var in createCollection instead of ref
Browse files Browse the repository at this point in the history
Just reduces the number of references for now, this function will need splitting later.
  • Loading branch information
AndrewSisley committed Oct 2, 2023
1 parent bb57b7e commit bc01ce5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions db/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ func (db *db) createCollection(
return nil, err
}

schema := col.desc.Schema
// Local elements such as secondary indexes should be excluded
// from the (global) schemaId.
schemaBuf, err := json.Marshal(col.desc.Schema)
schemaBuf, err := json.Marshal(schema)
if err != nil {
return nil, err
}
Expand All @@ -155,8 +156,9 @@ func (db *db) createCollection(
// For new schemas the initial version id will match the schema id
schemaVersionID := schemaID

col.desc.Schema.VersionID = schemaVersionID
col.desc.Schema.SchemaID = schemaID
schema.VersionID = schemaVersionID
schema.SchemaID = schemaID
col.desc.Schema = schema

// buffer must include all the ids, as it is saved and loaded from the store later.
buf, err := json.Marshal(col.desc)
Expand Down

0 comments on commit bc01ce5

Please sign in to comment.