Fix index creation for MySQL.

This commit is contained in:
Par Winzell
2009-04-08 18:52:08 +00:00
parent 9df2415678
commit a4dc9860de
2 changed files with 17 additions and 3 deletions
@@ -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;
@@ -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(");