Refactor generated code to use unified _params variable and add example generation script and tests #18
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.
What did this pull request do?
User Case Description
Introduce Example Generation Script and Refactor Example Query Interfaces and Tests
This pull request introduces a new script
scripts/gen-examples.shto automate the generation of development files for both typed and untyped example outputs. It refactors the exampleQueryinterface inexamples/query.goto use aParamsstruct for parameterized filtering, and propagates this change throughout example implementation, test code, and generated files for bothtypedandoutputvariants. The PR also standardizes parameter variable naming in all generated query methods to use_params, and ensures consistent handling of SQL parameters in code generation logic withininternal/gen/generator.goandinternal/gen/sqlparser.go. Additional and improved tests are added for all example query interfaces to ensure both compilation- and runtime-level correctness.Key Changes
• Added new script
scripts/gen-examples.shto generate typed and output examples automatically• Refactored
FilterByNameAndAgein theQueryinterface inexamples/query.goto accept a singleparams Paramsstruct instead of separate arguments• Introduced a new
Paramsstruct inexamples/query.goand updated all usages accordingly• Updated generated files in
examples/output/andexamples/typed/to reflect changes to parameter passing and interface signatures• Standardized on
_paramsas the parameter slice for SQL arguments across all generated code• Modified code generation logic in
internal/gen/generator.goandinternal/gen/sqlparser.goto use_params• Added new or improved test coverage for example query interfaces in
examples/query_test.go,examples/typed/query_test.go, andexamples/output/query_test.go• Updated SQL template rendering and related generator test cases to align with the new parameter convention
Affected Areas
•
examples/query.go(interface and struct definition, parameter passing)• Generated example files under
examples/typed/,examples/output/, and subfolders• Tests for query interfaces under
examples/,examples/typed/, andexamples/output/•
internal/gen/sqlparser.goandinternal/gen/generator.go(code generation logic)•
scripts/gen-examples.sh(new file)This summary was automatically generated by @propel-code-bot