Skip to content

Commit

Permalink
Fixup in SqlFormatter.
Browse files Browse the repository at this point in the history
  • Loading branch information
kovrus committed Jul 6, 2015
1 parent 2a3b17d commit e1e4b04
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions sql-parser/src/main/java/io/crate/sql/SqlFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
import static io.crate.sql.ExpressionFormatter.expressionFormatterFunction;
import static io.crate.sql.ExpressionFormatter.formatExpression;

public final class SqlFormatter
{
public final class SqlFormatter {
private static final String INDENT = " ";

private SqlFormatter() {}
Expand Down Expand Up @@ -247,7 +246,7 @@ public Void visitCreateTable(CreateTable node, Integer indent) {
}
}

if (node.properties().isPresent()) {
if (node.properties().isPresent() && !node.properties().get().isEmpty()) {
builder.append("\n");
node.properties().get().accept(this, indent);
}
Expand Down Expand Up @@ -323,7 +322,7 @@ public Void visitColumnType(ColumnType node, Integer indent) {
public Void visitObjectColumnType(ObjectColumnType node, Integer indent) {
builder.append("OBJECT");
if (node.objectType().isPresent()) {
builder.append(String.format(" (%s)", node.objectType().get()));
builder.append(String.format(" (%s)", node.objectType().get().toUpperCase(Locale.ENGLISH)));
}
if (!node.nestedColumns().isEmpty()) {
builder.append(" AS ");
Expand Down Expand Up @@ -378,6 +377,10 @@ public Void visitIndexDefinition(IndexDefinition node, Integer indent) {
.append(node.method().toUpperCase(Locale.ENGLISH))
.append(" ");
appendFlatNodeList(node.columns(), indent);
if (!node.properties().isEmpty()) {
builder.append(" ");
process(node.properties(), indent);
}
return null;
}

Expand Down

0 comments on commit e1e4b04

Please sign in to comment.