diff --git a/src/java/com/samskivert/depot/impl/BuildVisitor.java b/src/java/com/samskivert/depot/impl/BuildVisitor.java index e6688a4..1a05696 100644 --- a/src/java/com/samskivert/depot/impl/BuildVisitor.java +++ b/src/java/com/samskivert/depot/impl/BuildVisitor.java @@ -545,9 +545,7 @@ public abstract class BuildVisitor implements ExpressionVisitor } comma = true; - _builder.append("("); - field.left.accept(this); - _builder.append(")"); + appendIndexComponent(field.left); if (field.right == Order.DESC) { // ascending is default, print nothing unless explicitly descending _builder.append(" desc"); @@ -704,6 +702,15 @@ public abstract class BuildVisitor implements ExpressionVisitor "Persistent field has no definition [class=" + type + ", field=" + field + "]"); } + // output one of potentially many fields in an index expression + protected void appendIndexComponent (SQLExpression expression) + { + // the standard builder wraps each field in its own parens + _builder.append("("); + expression.accept(this); + _builder.append(")"); + } + protected BuildVisitor (DepotTypes types) { _types = types; diff --git a/src/java/com/samskivert/depot/impl/MySQLBuilder.java b/src/java/com/samskivert/depot/impl/MySQLBuilder.java index 153a4c6..e9088af 100644 --- a/src/java/com/samskivert/depot/impl/MySQLBuilder.java +++ b/src/java/com/samskivert/depot/impl/MySQLBuilder.java @@ -140,6 +140,13 @@ public class MySQLBuilder _builder.append(field); } + @Override + protected void appendIndexComponent (SQLExpression expression) + { + // MySQL is never given complex expressions and hates parens, so just recurse + expression.accept(this); + } + protected void renderMatch (FullText fullText) { _builder.append("match(");