[jOOQ/jOOQ#10189] Bad formatting when selecting NULL

This commit is contained in:
Lukas Eder 2020-05-11 17:03:06 +02:00
parent cb24f9d2b0
commit 28d484c442
2 changed files with 9 additions and 10 deletions

View File

@ -473,7 +473,7 @@ class DefaultRenderContext extends AbstractContext<RenderContext> implements Ren
@Override
public final boolean separatorRequired() {
return separatorRequired;
return separatorRequired && !separator && !newline;
}
@Override

View File

@ -114,10 +114,15 @@ class QueryPartCollectionView<T extends QueryPart> extends AbstractQueryPart imp
int size = rendersContent.cardinality();
boolean format = ctx.format() && size >= indentSize;
boolean previousQualify = ctx.qualify();
Object previousIndented = ctx.data(DATA_LIST_ALREADY_INDENTED);
boolean indent = format && !TRUE.equals(previousIndented);
if (qualify != null)
ctx.qualify(qualify);
if (indent)
ctx.formatIndentStart();
if (ctx.separatorRequired())
if (format)
ctx.formatSeparator();
@ -130,12 +135,6 @@ class QueryPartCollectionView<T extends QueryPart> extends AbstractQueryPart imp
}
else {
Object previousIndented = ctx.data(DATA_LIST_ALREADY_INDENTED);
boolean indent = format && !TRUE.equals(previousIndented);
if (indent)
ctx.formatIndentStart();
int j = 0;
int k = 0;
for (T part : this) {
@ -164,11 +163,11 @@ class QueryPartCollectionView<T extends QueryPart> extends AbstractQueryPart imp
else
ctx.visit(part);
}
if (indent)
ctx.formatIndentEnd().formatNewLine();
}
if (indent)
ctx.formatIndentEnd().formatNewLine();
if (qualify != null)
ctx.qualify(previousQualify);
}