Field Enhancements and Select Bind Fix#1428
Field Enhancements and Select Bind Fix#1428StrangeYear wants to merge 4 commits intogo-gorm:masterfrom
Conversation
There was a problem hiding this comment.
LGTM, ship it! 🚢
Details
Why was this auto-approved?
✅ APPROVED: All 1 generated comments were filtered by review level settings.
Filtered comments by type:
1 Critical Error
💡 These suggestions were filtered to reduce noise, but you can still see them by adjusting your review level settings.
Dismissing previous approval: 1 new comment(s) require attention based on Default policy
|
These helpers gracefully downgrade to standard LIKE/NOT LIKE semantics or the base aggregate form on non-PostgreSQL backends, and the select-expression plumbing now preserves the running bind offset while preventing SQL accumulation between statements. Affected Areas• This summary was automatically generated by @propel-code-bot |
Dismissing previous approval: 1 new comment(s) require attention based on Default policy
What did this pull request do?
This pull request enhances
gorm/genfield expression capabilities and fixes an issue related to bind variable index generation in parameterizedSELECTexpressions. It includes the following updates:Coalescefunction to field expressions.ILike/NotILikehelpers for PostgreSQL.Filterfunction to support PostgreSQLFILTER (WHERE ...)syntax in aggregate expressions.Select(...).New Features
Adds support for SQL
COALESCEinfield.Expr:Generates:
COALESCE("name", ?)Adds PostgreSQL case-insensitive pattern matching:
Generates:
Adds support for conditional aggregation:
Generates:
This allows clean construction of conditional aggregate expressions without falling back to raw SQL.
Bug Fix
Previously, when multiple
field.Exprvalues containing bind variables were passed intoSelect(...), each expression was built using a newgorm.Statement. This caused bind indexes to restart from$1for every expression (PostgreSQL), producing invalid SQL such as:instead of:
This PR fixes the issue by preserving bind index offsets across select expressions while still preventing SQL accumulation between statements.
The fix:
This change is considered a bug fix rather than a breaking change.
User Case Description
This PR enables advanced SQL construction in
gorm/gen:Select:Now correctly generates:
Compatibility
Selectusage unaffected