[jOOQ/jOOQ#13581] Remove more unnecessary unary op parentheses

- For bind values of internal types (non-custom Binding)
- For TableField
- For functions without emulations
This commit is contained in:
Lukas Eder 2022-05-20 09:59:35 +02:00
parent 0e1bfcfa46
commit 4fe70c0767
8 changed files with 44 additions and 0 deletions

View File

@ -89,6 +89,11 @@ implements
// XXX: QueryPart API
// -------------------------------------------------------------------------
@Override
final boolean parenthesised(Context<?> ctx) {
return true;
}
@Override
public final void accept(Context<?> ctx) {
switch (ctx.family()) {

View File

@ -57,6 +57,7 @@ import org.jooq.Param;
import org.jooq.ParamMode;
import org.jooq.QualifiedRecord;
import org.jooq.conf.ParamType;
import org.jooq.impl.DefaultBinding.InternalBinding;
import org.jooq.impl.QOM.NotYetImplementedException;
import org.jooq.tools.StringUtils;
@ -131,6 +132,14 @@ abstract class AbstractParam<T> extends AbstractParamX<T> implements SimpleQuery
// XXX: QueryPart API
// ------------------------------------------------------------------------
@Override
final boolean parenthesised(Context<?> ctx) {
// [#13581] User defined Binding implementations can generate any type
// of SQL, including SQL that isn't parenthesised.
return getBinding() instanceof InternalBinding;
}
@Override
public final Clause[] clauses(Context<?> ctx) {
return CLAUSES;

View File

@ -89,6 +89,11 @@ implements
// XXX: QueryPart API
// -------------------------------------------------------------------------
@Override
final boolean parenthesised(Context<?> ctx) {
return true;
}
@Override
public final void accept(Context<?> ctx) {
switch (ctx.family()) {

View File

@ -90,6 +90,11 @@ implements
// XXX: QueryPart API
// -------------------------------------------------------------------------
@Override
final boolean parenthesised(Context<?> ctx) {
return true;
}
@Override
public final void accept(Context<?> ctx) {
switch (ctx.family()) {

View File

@ -90,6 +90,11 @@ implements
// XXX: QueryPart API
// -------------------------------------------------------------------------
@Override
final boolean parenthesised(Context<?> ctx) {
return true;
}
@Override
public final void accept(Context<?> ctx) {
switch (ctx.family()) {

View File

@ -174,6 +174,11 @@ package org.jooq.impl;

View File

@ -97,6 +97,11 @@ class TableFieldImpl<R extends Record, T> extends AbstractField<T> implements Ta
// XXX: QueryPart API
// ------------------------------------------------------------------------
@Override
final boolean parenthesised(Context<?> ctx) {
return true;
}
@Override
public boolean declaresFields() {
return super.declaresFields();

View File

@ -90,6 +90,11 @@ implements
// XXX: QueryPart API
// -------------------------------------------------------------------------
@Override
final boolean parenthesised(Context<?> ctx) {
return true;
}
@Override
public final void accept(Context<?> ctx) {
switch (ctx.family()) {