Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add UID attribute.
Type of PR:
Details
I had to modify few parts.
Model constructor
Previously, we were simply instantiating model when registering it to the database, or using in repository. Instead, now model accepts
null
as the constructor argument. Whennull
is passed, all field value generation will be skipped.Usually, users should never pass
null
. But pre-registered models don't require fields. It's better for performance, but also it avoids calling uuid multiple times making it hard to mock inside the test. Maybe we could add helper static function to model to create a new model instance without field, because we might for get to pass null in the future when creating new attributes.Test
This is not new to this PR, but seems like we have to clear the model field registries on each test if we want to declare the same class in multiple test cases. For this, we can use
Model.clearRegistries()
. Note that we should not use this method for the test where we define class once and use same model in multiple tests. It is only for tests that define multiple same models.