diff --git a/jOOQ/src/main/java/org/jooq/impl/DSL.java b/jOOQ/src/main/java/org/jooq/impl/DSL.java index ef8000fbcb..831a19fc14 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DSL.java +++ b/jOOQ/src/main/java/org/jooq/impl/DSL.java @@ -6849,6 +6849,42 @@ public class DSL { return new SQLField(type, sql(sql, bindings)); } + /** + * Create a "plain SQL" field. + *
+ * This is useful for constructing more complex SQL syntax elements wherever
+ * Field types are expected. An example for this is MySQL's
+ * GROUP_CONCAT aggregate function, which has MySQL-specific
+ * keywords that are hard to reflect in jOOQ's DSL:
+ *
+ * GROUP_CONCAT([DISTINCT] expr [,expr ...]
+ * [ORDER BY {unsigned_integer | col_name | expr}
+ * [ASC | DESC] [,col_name ...]]
+ * [SEPARATOR str_val])
+ *
+ * The above MySQL function can be expressed as such:
+ *
+ * field("GROUP_CONCAT(DISTINCT {0} ORDER BY {1} ASC SEPARATOR '-')", expr1, expr2);
+ *
+ * NOTE: When inserting plain SQL into jOOQ objects, you must
+ * guarantee syntax integrity. You may also create the possibility of
+ * malicious SQL injection. Be sure to properly use bind variables and/or
+ * escape literals when concatenated into SQL clauses! One way to escape
+ * literals is to use {@link #name(String...)} and similar methods
+ *
+ * @param sql The SQL
+ * @param type The field type
+ * @param parts The {@link QueryPart} objects that are rendered at the
+ * {numbered placeholder} locations
+ * @return A field wrapping the plain SQL
+ * @see SQL
+ */
+ @Support
+ @PlainSQL
+ public static