Skip to content

Commit

Permalink
WIP - Use schema var in validateUpdateCollection 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 fe0be90 commit c50da00
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions db/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,21 +320,23 @@ func (db *db) validateUpdateCollection(
return false, NewErrCollectionIDDoesntMatch(proposedDesc.Name, existingDesc.ID, proposedDesc.ID)
}

if proposedDesc.Schema.SchemaID != existingDesc.Schema.SchemaID {
proposedSchema := proposedDesc.Schema
existingSchema := existingDesc.Schema
if proposedSchema.SchemaID != existingSchema.SchemaID {
return false, NewErrSchemaIDDoesntMatch(
proposedDesc.Name,
existingDesc.Schema.SchemaID,
proposedDesc.Schema.SchemaID,
existingSchema.SchemaID,
proposedSchema.SchemaID,
)
}

if proposedDesc.Schema.Name != existingDesc.Schema.Name {
if proposedSchema.Name != existingSchema.Name {
// There is actually little reason to not support this atm besides controlling the surface area
// of the new feature. Changing this should not break anything, but it should be tested first.
return false, NewErrCannotModifySchemaName(existingDesc.Schema.Name, proposedDesc.Schema.Name)
return false, NewErrCannotModifySchemaName(existingSchema.Name, proposedSchema.Name)
}

if proposedDesc.Schema.VersionID != "" && proposedDesc.Schema.VersionID != existingDesc.Schema.VersionID {
if proposedSchema.VersionID != "" && proposedSchema.VersionID != existingSchema.VersionID {
// If users specify this it will be overwritten, an error is prefered to quietly ignoring it.
return false, ErrCannotSetVersionID
}
Expand Down

0 comments on commit c50da00

Please sign in to comment.