-
-
Notifications
You must be signed in to change notification settings - Fork 349
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
Struct validation #186
Merged
Merged
Struct validation #186
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…otosocial into struct_validation
…otosocial into struct_validation
NyaaaWhatsUpDoc
requested changes
Sep 3, 2021
Just ran this PR with SQLite and confirmed all tests are passing. Aside from mentioned issues, looks good! |
NyaaaWhatsUpDoc
requested changes
Sep 3, 2021
This was referenced Sep 3, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds validation tags for all database model structs, and adds a struct validator in
internal/validate
, as well as tests for all of the defined structs.It also reworks some of the structure of the packages to make a bit more sense, and adds a stub for Bun migration.
gtsmodel
is now the only place that contains structs that enter the database, and it only contains structs that enter the database. Reason for this: when we do migrations, we can basically copy-paste whatever the current state of gtsmodel is into a subfolder of migrations that pertains to the specific migration ID, so each migration has a copy of the gtsmodels it pertains to, as they were at the time the migration was created. This will make it easier to play back or forward from a specific migration.Note that this test doesn't actually hook the validation into the database logic yet, it only adds struct tags and validation tests to prepare for creating these db hooks in future
Interesting stuff in the PR starts from here downwards:
https://github.com/superseriousbusiness/gotosocial/pull/186/files#diff-7c8fa43ec6d65ce61a4f0617935c0e2fae26f679ffb4ac43ac06f41437521fd3
Tests are here onwards: https://github.com/superseriousbusiness/gotosocial/pull/186/files#diff-52727fb181f9f77e0dc72951e43903d0fc5355ed355f71923fb91d2c60518c16