fix: add SQLExpressions.stringAgg and ensure proper spacing for WITHI… #1258
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.
📝 Pull-Request Description
What & Why
PostgreSQL’s
string_agg( … ) WITHIN GROUP (ORDER BY …)
was rendered without the required space beforeWITHIN GROUP
, producing invalid SQL such asThe root cause is documented in the upstream bug report
➡️ [querydsl/querydsl #3851](querydsl/querydsl#3851).
This PR ports the fix to the
openfeign/querydsl
fork so downstream consumers get the corrected SQL generation.Changes in this PR
querydsl-sql/src/main/java/com/querydsl/sql/dsl/SQLExpressions.java
stringAgg(Expression<String>, Expression<?> separator)
convenience method, mirroring other aggregate helpers and enabling fluentwithinGroup().orderBy(… )
chaining.querydsl-sql/src/main/java/com/querydsl/sql/PostgreSQLTemplates.java
string_agg
andWITHIN GROUP
, producing valid SQL.querydsl-sql/src/test/java/.../StringAggWithinGroupOrderByTest.java
string_agg(foo.name,';') WITHIN GROUP (ORDER BY foo.id asc)
; fails on old code, passes after fix.Before vs. After
string_agg(foo.name,';')WITHIN GROUP(ORDER BY foo.id asc)
string_agg(foo.name,';') WITHIN GROUP (ORDER BY foo.id asc)
Compatibility
stringAgg
) and template fix.Tests & CI
easy-jacoco-maven-plugin
resolution and is unrelated to this patch. I can follow up with a workflow or version pin if desired.Related
🤝 Thanks for reviewing!