Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Remove collection from patch schema #1957

Merged

Conversation

AndrewSisley
Copy link
Contributor

@AndrewSisley AndrewSisley commented Oct 10, 2023

Relevant issue(s)

Resolves #1956

Description

Removes collectionDescription from patch schema.

PatchSchema now only uses collectionDescription internally to update it if requested (bool param).

This now means that the only place remaining (minus a util func that got missed) that refs collectionDescription.Schema should be the serialization. This will be sorted out in a later PR, before removal of the property completely.

@AndrewSisley AndrewSisley added feature New feature or request area/schema Related to the schema system code quality Related to improving code quality labels Oct 10, 2023
@AndrewSisley AndrewSisley added this to the DefraDB v0.8 milestone Oct 10, 2023
@AndrewSisley AndrewSisley requested a review from a team October 10, 2023 22:31
@AndrewSisley AndrewSisley self-assigned this Oct 10, 2023
@AndrewSisley AndrewSisley changed the title feature: Remove collection from patch schema feat: Remove collection from patch schema Oct 10, 2023
@codecov
Copy link

codecov bot commented Oct 10, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (25d4767) 74.48% compared to head (fe8bde0) 74.25%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1957      +/-   ##
===========================================
- Coverage    74.48%   74.25%   -0.23%     
===========================================
  Files          242      242              
  Lines        23479    23436      -43     
===========================================
- Hits         17486    17401      -85     
- Misses        4812     4847      +35     
- Partials      1181     1188       +7     
Flag Coverage Δ
all-tests 74.25% <100.00%> (-0.23%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
db/collection.go 69.41% <100.00%> (-1.34%) ⬇️
db/schema.go 85.33% <100.00%> (+0.07%) ⬆️

... and 9 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 25d4767...fe8bde0. Read the comment docs.

AndrewSisley added a commit to AndrewSisley/defradb that referenced this pull request Oct 12, 2023
db/schema.go Outdated
fieldIndexesByName := make(map[string]int, len(col.Schema.Fields))
fieldIndexesByCollection[colName] = fieldIndexesByName
for i, field := range col.Schema.Fields {
fieldIndexesByCollection := make(map[string]map[string]int, len(schemaByName))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: fieldIndexesBySchema

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cheers, changing :)

  • Rename var to fieldIndexesBySchema

db/collection.go Outdated
@@ -228,12 +206,19 @@ func (db *db) createCollection(
func (db *db) updateCollection(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: Spotted by Fred - this should no longer be called updateCollection.

  • Rename to updateSchema

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing that it should also be moved to schema.go

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be co-located with the other functions that update the descriptions (including the future patchCollection), spreading those functions out will not aid readability.

Your thought should be re-visited in #1963 once everything in this space makes a little more sense and we can move everything together.

db/schema.go Outdated Show resolved Hide resolved
db/schema.go Outdated
Comment on lines 139 to 149
for _, schema := range newSchemaByName {
if schema.Name == "" {
return ErrSchemaNameEmpty
}

collectionDescription, ok := collectionsByName[schema.Name]
if !ok {
return NewErrAddCollectionWithPatch(schema.Name)
}

col, err := db.newCollection(collectionDescription, schema)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: If we change the current updateCollection to updateSchema, we will still need an updateCollection function to handle the collection specific update to the new schema version. This part might be better off in that new updateCollection function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be handled in #1963 and #1963 - it was going to be done in #1965 but it proved to be a large undertaking to do it properly.

AndrewSisley added a commit to AndrewSisley/defradb that referenced this pull request Oct 17, 2023
Copy link
Collaborator

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@AndrewSisley AndrewSisley merged commit 20b6329 into sourcenetwork:develop Oct 17, 2023
29 checks passed
@AndrewSisley AndrewSisley deleted the 1956-rm-col-from-patch-schema branch October 17, 2023 16:17
nasdf pushed a commit to nasdf/defradb that referenced this pull request Oct 18, 2023
## Relevant issue(s)

Resolves sourcenetwork#1956

## Description

Removes collectionDescription from patch schema.

PatchSchema now only uses collectionDescription internally to update it
if requested (bool param).

This now means that the only place remaining (minus a util func that got
missed) that refs collectionDescription.Schema should be the
serialization. This will be sorted out in a later PR, before removal of
the property completely.
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
## Relevant issue(s)

Resolves sourcenetwork#1956

## Description

Removes collectionDescription from patch schema.

PatchSchema now only uses collectionDescription internally to update it
if requested (bool param).

This now means that the only place remaining (minus a util func that got
missed) that refs collectionDescription.Schema should be the
serialization. This will be sorted out in a later PR, before removal of
the property completely.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/schema Related to the schema system code quality Related to improving code quality feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove collection from PatchSchema
2 participants