Avoid rendering unnecessary parenthesis for junctions
This commit is contained in:
parent
cd555de724
commit
afdedb0fc5
|
@ -5076,10 +5076,18 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
|
||||||
}
|
}
|
||||||
|
|
||||||
private void visitJunctionPredicate(Junction.Nature nature, Predicate p) {
|
private void visitJunctionPredicate(Junction.Nature nature, Predicate p) {
|
||||||
if ( p instanceof Junction && nature != ( (Junction) p ).getNature() ) {
|
if ( p instanceof Junction ) {
|
||||||
appendSql( OPEN_PARENTHESIS );
|
final Junction junction = (Junction) p;
|
||||||
p.accept( this );
|
// If we have the same nature, or if this is a disjunction and the operand is a conjunction,
|
||||||
appendSql( CLOSE_PARENTHESIS );
|
// then we don't need parenthesis, because the AND operator binds stronger
|
||||||
|
if ( nature == junction.getNature() || nature == Junction.Nature.DISJUNCTION ) {
|
||||||
|
p.accept( this );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
appendSql( OPEN_PARENTHESIS );
|
||||||
|
p.accept( this );
|
||||||
|
appendSql( CLOSE_PARENTHESIS );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
p.accept( this );
|
p.accept( this );
|
||||||
|
|
Loading…
Reference in New Issue