[jOOQ/jOOQ#11757] Add Settings.renderCoalesceToEmptyStringInConcat
This commit is contained in:
parent
203f1b95db
commit
4579c7ce8d
@ -85,6 +85,8 @@ public class Settings
|
||||
@XmlElement(defaultValue = "IMPLICIT_NULL")
|
||||
@XmlSchemaType(name = "string")
|
||||
protected RenderDefaultNullability renderDefaultNullability = RenderDefaultNullability.IMPLICIT_NULL;
|
||||
@XmlElement(defaultValue = "false")
|
||||
protected Boolean renderCoalesceToEmptyStringInConcat = false;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean renderOrderByRownumberForEmulatedPagination = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
@ -700,6 +702,35 @@ public class Settings
|
||||
this.renderDefaultNullability = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether stored function calls should be wrapped in scalar subqueries.
|
||||
* <p>
|
||||
* Oracle 11g (and potentially, other databases too) implements scalar subquery caching. With this flag
|
||||
* set to true, users can automatically profit from this feature in all SQL statements.
|
||||
* <p>
|
||||
* This feature is available in the commercial distribution only.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public Boolean isRenderCoalesceToEmptyStringInConcat() {
|
||||
return renderCoalesceToEmptyStringInConcat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the renderCoalesceToEmptyStringInConcat property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public void setRenderCoalesceToEmptyStringInConcat(Boolean value) {
|
||||
this.renderCoalesceToEmptyStringInConcat = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether an additional <code>ORDER BY rn</code> clause should be rendered on emulated paginated queries.
|
||||
* <p>
|
||||
@ -2829,6 +2860,11 @@ public class Settings
|
||||
return this;
|
||||
}
|
||||
|
||||
public Settings withRenderCoalesceToEmptyStringInConcat(Boolean value) {
|
||||
setRenderCoalesceToEmptyStringInConcat(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Settings withRenderOrderByRownumberForEmulatedPagination(Boolean value) {
|
||||
setRenderOrderByRownumberForEmulatedPagination(value);
|
||||
return this;
|
||||
@ -3564,6 +3600,7 @@ public class Settings
|
||||
builder.append("renderScalarSubqueriesForStoredFunctions", renderScalarSubqueriesForStoredFunctions);
|
||||
builder.append("renderImplicitJoinType", renderImplicitJoinType);
|
||||
builder.append("renderDefaultNullability", renderDefaultNullability);
|
||||
builder.append("renderCoalesceToEmptyStringInConcat", renderCoalesceToEmptyStringInConcat);
|
||||
builder.append("renderOrderByRownumberForEmulatedPagination", renderOrderByRownumberForEmulatedPagination);
|
||||
builder.append("renderOutputForSQLServerReturningClause", renderOutputForSQLServerReturningClause);
|
||||
builder.append("renderParenthesisAroundSetOperationQueries", renderParenthesisAroundSetOperationQueries);
|
||||
@ -3847,6 +3884,15 @@ public class Settings
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (renderCoalesceToEmptyStringInConcat == null) {
|
||||
if (other.renderCoalesceToEmptyStringInConcat!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!renderCoalesceToEmptyStringInConcat.equals(other.renderCoalesceToEmptyStringInConcat)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (renderOrderByRownumberForEmulatedPagination == null) {
|
||||
if (other.renderOrderByRownumberForEmulatedPagination!= null) {
|
||||
return false;
|
||||
@ -4692,6 +4738,7 @@ public class Settings
|
||||
result = ((prime*result)+((renderScalarSubqueriesForStoredFunctions == null)? 0 :renderScalarSubqueriesForStoredFunctions.hashCode()));
|
||||
result = ((prime*result)+((renderImplicitJoinType == null)? 0 :renderImplicitJoinType.hashCode()));
|
||||
result = ((prime*result)+((renderDefaultNullability == null)? 0 :renderDefaultNullability.hashCode()));
|
||||
result = ((prime*result)+((renderCoalesceToEmptyStringInConcat == null)? 0 :renderCoalesceToEmptyStringInConcat.hashCode()));
|
||||
result = ((prime*result)+((renderOrderByRownumberForEmulatedPagination == null)? 0 :renderOrderByRownumberForEmulatedPagination.hashCode()));
|
||||
result = ((prime*result)+((renderOutputForSQLServerReturningClause == null)? 0 :renderOutputForSQLServerReturningClause.hashCode()));
|
||||
result = ((prime*result)+((renderParenthesisAroundSetOperationQueries == null)? 0 :renderParenthesisAroundSetOperationQueries.hashCode()));
|
||||
|
||||
@ -137,6 +137,10 @@ abstract class AbstractField<T> extends AbstractTypedNamed<T> implements Field<T
|
||||
return CLAUSES;
|
||||
}
|
||||
|
||||
/* non-final */ boolean isPossiblyNullable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// [#5518] Record method inversions, e.g. for use as method references
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@ -87,6 +87,11 @@ abstract class AbstractParam<T> extends AbstractParamX<T> implements SimpleQuery
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
final boolean isPossiblyNullable() {
|
||||
return !inline || value == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A utility method that generates a field name.
|
||||
* <p>
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.DSL.function;
|
||||
import static org.jooq.impl.DSL.inline;
|
||||
import static org.jooq.impl.ExpressionOperator.ADD;
|
||||
import static org.jooq.impl.ExpressionOperator.BIT_AND;
|
||||
import static org.jooq.impl.ExpressionOperator.CONCAT;
|
||||
@ -71,6 +72,14 @@ final class Concat extends AbstractField<String> {
|
||||
// [#461] Type cast the concat expression, if this isn't a VARCHAR field
|
||||
Field<String>[] cast = castAllIfNeeded(arguments, String.class);
|
||||
|
||||
if (Boolean.TRUE.equals(ctx.settings().isRenderCoalesceToEmptyStringInConcat()) && ctx.configuration().commercial(() -> "Auto-coalescing of CONCAT arguments is available in the jOOQ 3.15 Professional Edition and jOOQ Enterprise Edition, see https://github.com/jOOQ/jOOQ/issues/11757")) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// If there is only one argument, return it immediately
|
||||
if (cast.length == 1) {
|
||||
ctx.visit(cast[0]);
|
||||
|
||||
@ -3136,6 +3136,10 @@ final class Tools {
|
||||
return part instanceof SimpleQueryPart && ((SimpleQueryPart) part).isSimple();
|
||||
}
|
||||
|
||||
static final boolean isPossiblyNullable(Field<?> f) {
|
||||
return f instanceof AbstractField && ((AbstractField<?>) f).isPossiblyNullable();
|
||||
}
|
||||
|
||||
static final Val<?> extractVal(Field<?> field) {
|
||||
return field instanceof Val
|
||||
? (Val<?>) field
|
||||
|
||||
@ -140,6 +140,15 @@ set to true, users can automatically profit from this feature in all SQL stateme
|
||||
<element name="renderDefaultNullability" type="jooq-runtime:RenderDefaultNullability" minOccurs="0" maxOccurs="1" default="IMPLICIT_NULL">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Whether the {@link org.jooq.Nullability#DEFAULT} nullablity should be rendered in generated DDL, and how it should be rendered.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="renderCoalesceToEmptyStringInConcat" type="boolean" minOccurs="0" maxOccurs="1" default="false">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Whether stored function calls should be wrapped in scalar subqueries.
|
||||
<p>
|
||||
Oracle 11g (and potentially, other databases too) implements scalar subquery caching. With this flag
|
||||
set to true, users can automatically profit from this feature in all SQL statements.
|
||||
<p>
|
||||
This feature is available in the commercial distribution only.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="renderOrderByRownumberForEmulatedPagination" type="boolean" minOccurs="0" maxOccurs="1" default="true">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Whether an additional <code>ORDER BY rn</code> clause should be rendered on emulated paginated queries.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user