Skip to content

Conversation

@winebarrel
Copy link
Member

No description provided.

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 adds support for customizing the Queryer type name in generated code. Previously, the generated methods always used a hardcoded "Queryer" type for database parameters. Now users can specify a custom type name via the --queryer flag, allowing integration with custom database interface types.

Changes:

  • Added --queryer command-line flag to specify custom Queryer type name
  • Modified templates and code generation to use the custom Queryer type instead of hardcoded "Queryer"
  • Updated all test cases to pass the new queryer parameter with empty string (defaulting to "Queryer")
  • Added new test case to verify custom Queryer type generation

Reviewed changes

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

Show a summary per file
File Description
main.go Added --queryer flag and passed it to PgCreateStruct function
dgw.go Added Queryer field to Struct type and updated PgTableToStruct and PgCreateStruct to accept and use custom queryer parameter
template/method.tmpl Updated all method signatures to use {{ .Struct.Queryer }} instead of hardcoded "Queryer"
dgw_test.go Updated all test function calls to pass empty string for queryer parameter, and added comprehensive test for custom Queryer functionality
README.md Added documentation for the new --queryer flag
Comments suppressed due to low confidence (1)

main.go:52

  • When a custom queryer type name is specified via the --queryer flag, the code still appends the hardcoded Queryer interface definition from queryInterface constant. This creates a mismatch where generated methods reference a custom type (e.g., MyQueryer) but the appended interface is still named Queryer. Consider either: (1) not appending the interface when a custom queryer is specified, (2) dynamically generating the interface with the custom name, or (3) documenting that users must define their own interface when using a custom queryer name.
		q := []byte(queryInterface)
		src = append(st, q...)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@winebarrel winebarrel merged commit ae132be into master Jan 15, 2026
12 checks passed
@winebarrel winebarrel deleted the support-custom-queryer branch January 15, 2026 05:08
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