Feat: Select(): Implement batch relation loading instead of loading recursively which would have caused an N+1 problem - #12
Merged
Conversation
…ecursively which would have caused an N+1 problem 1- refactor delegates into model structs, relations, header, and create in the templates 2- refactor the client generation into a core client and per model file so code is easy to navigate 3- add bindVars() in client that uses the dialect's bindVar() in the relationships construction 4- add fkForRelation() in helpers to explicitly include the FK when a relation is selected 5- add missing dialect to the transaction template which caused nil pointer ref panic on tx execution 6- add conditional dialect in the client template to only generate the dialect for the specified provider 7- update generator.go and handleGenerate.go to output multiple files mapped by filename instead of a single giant client.go 8- add integration/selection_test.go verifying Select/Omit fields and deep batch relation loading 9- add integration/benchmark_test.go comparing ORM against raw SQL and raw SQL + scan + CUID in creation 10- optimize query compiler in execution layer using strings.Builder with sb.Grow() to prevent heap allocations 11- cache default model columns statically in model structs for O(1) select resolution if none are selected 12- add lint target, benchmark to makefile to run staticcheck and gocritic linter checks and to run the benchmark
This file contains hidden or 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
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.
1- refactor delegates into model structs, relations, header, and create in the templates
2- refactor the client generation into a core client and per model file so code is easy to navigate
3- add bindVars() in client that uses the dialect's bindVar() in the relationships construction
4- add fkForRelation() in helpers to explicitly include the FK when a relation is selected
5- add missing dialect to the transaction template which caused nil pointer ref panic on tx execution
6- add conditional dialect in the client template to only generate the dialect for the specified provider
7- update generator.go and handleGenerate.go to output multiple files mapped by filename instead of a single giant client.go
8- add integration/selection_test.go verifying Select/Omit fields and deep batch relation loading
9- add integration/benchmark_test.go comparing ORM against raw SQL and raw SQL + scan + CUID in creation
10- optimize query compiler in execution layer using strings.Builder with sb.Grow() to prevent heap allocations
11- cache default model columns statically in model structs for O(1) select resolution if none are selected
12- add lint target, benchmark to makefile to run staticcheck and gocritic linter checks and to run the benchmark