-
Notifications
You must be signed in to change notification settings - Fork 44
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
fix: Assert fields exist in collection before saving to them #604
fix: Assert fields exist in collection before saving to them #604
Conversation
def69ca
to
9750553
Compare
Codecov Report
@@ Coverage Diff @@
## develop #604 +/- ##
===========================================
+ Coverage 56.36% 56.41% +0.04%
===========================================
Files 121 121
Lines 14303 14316 +13
===========================================
+ Hits 8062 8076 +14
+ Misses 5543 5542 -1
Partials 698 698
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving assuming my two concerns are addressed :)
db/collection.go
Outdated
return core.DataStoreKey{ | ||
CollectionId: key.CollectionId, | ||
DocKey: key.DocKey, | ||
FieldId: fmt.Sprint(c.getSchemaFieldID(fieldName)), | ||
} | ||
FieldId: fmt.Sprint(fieldId), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: I suggestion using something a little more efficient than Sprint
.
FieldId: fmt.Sprint(fieldId), | |
FieldId: strconv.FormatUint(uint64(fieldId), 10), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is a surprising performance gap between the two, and a bit odd fmt.Sprint doesnt take advantage of this. Will use strconv.Iota as that reads better. Thanks for flagging - is for sure good to know
https://developpaper.com/performance-test-of-several-methods-based-on-go-int-to-string/
- do it this way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah Iota only takes an int, which could technically overflow on a 32 bit machine - will use strconv.FormatUint
as originally suggested. Really weird that Golang doesnt have a nicer way of doing this.
tests/integration/utils.go
Outdated
@@ -78,6 +78,9 @@ type QueryTestCase struct { | |||
// updates is a map from document index, to a list | |||
// of changes in strinigied JSON format | |||
Updates map[int]map[int][]string | |||
|
|||
CollectionCalls map[int]func(client.Collection) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: can we call this UpdateFuncs
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a problem, will do
- Rename
Panic hides any expected errors in case results are still returned
9750553
to
b591f94
Compare
Should allow us to assert collection-abi functionality within the main integration test suite
b591f94
to
26ec210
Compare
…etwork#604) * Check expected length before accessing index Panic hides any expected errors in case results are still returned * Add support for collection abi calls in tests Should allow us to assert collection-abi functionality within the main integration test suite * Error if field does not exist
Relevant issue(s)
Resolves #573
Description
Asserts that fields exist in collection before saving to them. Issue made a lot easier by Shahzad spotting the
return 0
in collection.go. Also adds support for testing the collection abi within our test framework - should hopefully make testing it much easier going forward.Tasks
Specify the platform(s) on which this was tested: