You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a new `CONSTBIND` option that allows using `${expr}` syntax for
compile-time parameter binding without template rendering overhead.
Features:
- Extract `${...}` expressions from SQL and replace with `?` placeholders
- Support any Go expression including variables, struct fields, and function calls
- Properly handle quoted strings (expressions inside quotes are preserved)
- Support nested braces for complex expressions like `${map[string]int{}}`
Example usage:
```go
// GetUser query constbind
// SELECT * FROM user WHERE name = ${user.Name} AND age > ${user.Age};
GetUser(ctx context.Context, user *User) (*User, error)
```
Changes:
- gen/method.go: Add parseConstBindExpressions() function
- gen/sqlx.go: Add constBindSQL and constBindArgs template functions
- gen/template/sqlx.tmpl: Support CONSTBIND option in template
- gen/method_test.go: Add unit tests for expression parsing
- gen/sqlx_test.go: Add build test for constbind
- gen/integration/sqlx/main.go: Add integration tests
- README.md: Document the new feature
- CLAUDE.md: Update with constbind information
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
0 commit comments