diff --git a/jOOQ-manual/src/main/resources/org/jooq/web/grammar-3.11.txt b/jOOQ-manual/src/main/resources/org/jooq/web/grammar-3.11.txt index 460c652f91..e8952468f6 100644 --- a/jOOQ-manual/src/main/resources/org/jooq/web/grammar-3.11.txt +++ b/jOOQ-manual/src/main/resources/org/jooq/web/grammar-3.11.txt @@ -498,7 +498,10 @@ predicate = row2 = [ 'ROW' ] '(' field ',' field ')' ; -concat = sum { '||' sum } +concat = collated { '||' collated } +; + +collated = sum [ 'COLLATE' collation ] ; sum = factor { ( '+' | '-' ) factor } @@ -789,6 +792,9 @@ fieldNames = fieldName { ',' fieldName } fieldName = name ; +collation = name +; + name = identifier { '.' identifier } ; diff --git a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java index 6e1fc0964b..5717fd4304 100644 --- a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java @@ -58,6 +58,7 @@ import static org.jooq.impl.DSL.charLength; import static org.jooq.impl.DSL.check; import static org.jooq.impl.DSL.choose; import static org.jooq.impl.DSL.coalesce; +import static org.jooq.impl.DSL.collation; import static org.jooq.impl.DSL.concat; import static org.jooq.impl.DSL.condition; import static org.jooq.impl.DSL.constraint; @@ -259,6 +260,7 @@ import org.jooq.CaseConditionStep; import org.jooq.CaseValueStep; import org.jooq.CaseWhenStep; import org.jooq.Catalog; +import org.jooq.Collation; import org.jooq.Comment; import org.jooq.CommentOnIsStep; import org.jooq.CommonTableExpression; @@ -3424,11 +3426,21 @@ final class ParserImpl implements Parser { } private static final FieldOrRow parseConcat(ParserContext ctx, Type type) { - FieldOrRow r = parseSum(ctx, type); + FieldOrRow r = parseCollated(ctx, type); if (S.is(type) && r instanceof Field) while (parseIf(ctx, "||")) - r = concat((Field) r, toField(ctx, parseSum(ctx, type))); + r = concat((Field) r, toField(ctx, parseCollated(ctx, type))); + + return r; + } + + private static final FieldOrRow parseCollated(ParserContext ctx, Type type) { + FieldOrRow r = parseSum(ctx, type); + + if (S.is(type) && r instanceof Field) + if (parseKeywordIf(ctx, "COLLATE")) + r = ((Field) r).collate(parseCollation(ctx)); return r; } @@ -5746,6 +5758,10 @@ final class ParserImpl implements Parser { return null; } + private static final Collation parseCollation(ParserContext ctx) { + return collation(parseName(ctx)); + } + private static final Name parseName(ParserContext ctx) { Name result = parseNameIf(ctx);