Skip to content

Conversation

@jinzhu
Copy link
Member

@jinzhu jinzhu commented Sep 16, 2025

  • Do only one thing
  • Non breaking API changes
  • Tested

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.sh to automate the generation of development files for both typed and untyped example outputs. It refactors the example Query interface in examples/query.go to use a Params struct for parameterized filtering, and propagates this change throughout example implementation, test code, and generated files for both typed and output variants. 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 within internal/gen/generator.go and internal/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.sh to generate typed and output examples automatically
• Refactored FilterByNameAndAge in the Query interface in examples/query.go to accept a single params Params struct instead of separate arguments
• Introduced a new Params struct in examples/query.go and updated all usages accordingly
• Updated generated files in examples/output/ and examples/typed/ to reflect changes to parameter passing and interface signatures
• Standardized on _params as the parameter slice for SQL arguments across all generated code
• Modified code generation logic in internal/gen/generator.go and internal/gen/sqlparser.go to use _params
• Added new or improved test coverage for example query interfaces in examples/query_test.go, examples/typed/query_test.go, and examples/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/, and examples/output/
internal/gen/sqlparser.go and internal/gen/generator.go (code generation logic)
scripts/gen-examples.sh (new file)


This summary was automatically generated by @propel-code-bot

@propel-code-bot propel-code-bot bot changed the title Add generate example script and more tests for query interfaces defined in example package Refactor generated code to use unified _params variable and add example generation script and tests Sep 16, 2025
@jinzhu jinzhu requested a review from Copilot September 16, 2025 14:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the generated SQL query code to use a unified _params variable name instead of params, and updates the API to use a structured Params type for parameter passing. It also includes a new shell script for generating development examples and comprehensive test coverage.

  • Standardizes parameter variable naming from params to _params across all generated code
  • Replaces primitive parameter passing with a structured Params type containing Name and Age fields
  • Adds development tooling including a generation script and test files

Reviewed Changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated no comments.

Show a summary per file
File Description
scripts/gen-examples.sh New shell script for generating typed and untyped example files
internal/gen/sqlparser.go Updates parameter variable name from params to _params in code generation
internal/gen/generator.go Updates generated method bodies to use _params variable
examples/query.go Changes API from primitive parameters to structured Params type
examples/query_test.go New test file for validating query interfaces and parameter structures
examples/typed/query.go Generated code updated with _params variable and structured parameters
examples/output/query.go Generated code updated with _params variable and structured parameters
various filter files All generated filter code updated to use _params variable naming

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@jinzhu jinzhu merged commit 6ac28f0 into master Sep 16, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants