[jOOQ/jOOQ#5799] Fix tests and regressions
This commit is contained in:
parent
c34f0a9a8e
commit
2b9b352ec1
@ -1615,16 +1615,12 @@ final class Tools {
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
private static final int FIELD_NAME_CACHE_SIZE = 128;
|
||||
private static final String[] V_FIELD_NAME_STRINGS;
|
||||
private static final String[] C_FIELD_NAME_STRINGS;
|
||||
private static final Name[] V_FIELD_NAMES;
|
||||
private static final Name[] C_FIELD_NAMES;
|
||||
private static final String[] FIELD_NAME_STRINGS;
|
||||
private static final Name[] FIELD_NAMES;
|
||||
|
||||
static {
|
||||
V_FIELD_NAME_STRINGS = IntStream.range(0, FIELD_NAME_CACHE_SIZE).mapToObj(Tools::fieldNameStringV0).toArray(String[]::new);
|
||||
C_FIELD_NAME_STRINGS = IntStream.range(0, FIELD_NAME_CACHE_SIZE).mapToObj(Tools::fieldNameStringC0).toArray(String[]::new);
|
||||
V_FIELD_NAMES = IntStream.range(0, FIELD_NAME_CACHE_SIZE).mapToObj(i -> name(V_FIELD_NAME_STRINGS[i])).toArray(Name[]::new);
|
||||
C_FIELD_NAMES = IntStream.range(0, FIELD_NAME_CACHE_SIZE).mapToObj(i -> name(C_FIELD_NAME_STRINGS[i])).toArray(Name[]::new);
|
||||
FIELD_NAME_STRINGS = IntStream.range(0, FIELD_NAME_CACHE_SIZE).mapToObj(Tools::fieldNameString0).toArray(String[]::new);
|
||||
FIELD_NAMES = IntStream.range(0, FIELD_NAME_CACHE_SIZE).mapToObj(i -> name(FIELD_NAME_STRINGS[i])).toArray(Name[]::new);
|
||||
}
|
||||
|
||||
static final <T> SortField<T> sortField(OrderField<T> field) {
|
||||
@ -1648,28 +1644,16 @@ final class Tools {
|
||||
}
|
||||
|
||||
// TODO: Check if these field names are ever really needed, or if we can just use the C field names
|
||||
private static final String fieldNameStringV0(int index) {
|
||||
private static final String fieldNameString0(int index) {
|
||||
return "v" + index;
|
||||
}
|
||||
|
||||
private static final String fieldNameStringC0(int index) {
|
||||
return "c" + (index + 1);
|
||||
}
|
||||
|
||||
static final String fieldNameString(int index) {
|
||||
return index < FIELD_NAME_CACHE_SIZE ? V_FIELD_NAME_STRINGS[index] : fieldNameStringV0(index);
|
||||
}
|
||||
|
||||
static final String fieldNameStringC(int index) {
|
||||
return index < FIELD_NAME_CACHE_SIZE ? C_FIELD_NAME_STRINGS[index] : fieldNameStringC0(index);
|
||||
return index < FIELD_NAME_CACHE_SIZE ? FIELD_NAME_STRINGS[index] : fieldNameString0(index);
|
||||
}
|
||||
|
||||
static final Name fieldName(int index) {
|
||||
return index < FIELD_NAME_CACHE_SIZE ? V_FIELD_NAMES[index] : name(fieldNameStringV0(index));
|
||||
}
|
||||
|
||||
static final Name fieldNameC(int index) {
|
||||
return index < FIELD_NAME_CACHE_SIZE ? C_FIELD_NAMES[index] : name(fieldNameStringC0(index));
|
||||
return index < FIELD_NAME_CACHE_SIZE ? FIELD_NAMES[index] : name(fieldNameString0(index));
|
||||
}
|
||||
|
||||
static final Name[] fieldNames(int length) {
|
||||
@ -1690,24 +1674,6 @@ final class Tools {
|
||||
return result;
|
||||
}
|
||||
|
||||
static final Name[] fieldNamesC(int length) {
|
||||
Name[] result = new Name[length];
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
result[i] = fieldNameC(i);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static final String[] fieldNameStringsC(int length) {
|
||||
String[] result = new String[length];
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
result[i] = fieldNameStringC(i);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static final Field<?>[] fields(int length) {
|
||||
return fields(length, SQLDataType.OTHER);
|
||||
}
|
||||
|
||||
@ -66,11 +66,9 @@ import static org.jooq.impl.Keywords.K_STRUCT;
|
||||
import static org.jooq.impl.Keywords.K_TABLE;
|
||||
import static org.jooq.impl.Keywords.K_UNNEST;
|
||||
import static org.jooq.impl.Keywords.K_VALUES;
|
||||
import static org.jooq.impl.Names.N_VALUES;
|
||||
import static org.jooq.impl.QueryPartListView.wrap;
|
||||
import static org.jooq.impl.SubqueryCharacteristics.DERIVED_TABLE;
|
||||
import static org.jooq.impl.Tools.EMPTY_ROW;
|
||||
import static org.jooq.impl.Tools.fieldNamesC;
|
||||
import static org.jooq.impl.Tools.isEmpty;
|
||||
import static org.jooq.impl.Tools.map;
|
||||
import static org.jooq.impl.Tools.visitSubquery;
|
||||
@ -87,7 +85,6 @@ import org.jooq.Row;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.Select;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableOptions;
|
||||
import org.jooq.conf.ParamType;
|
||||
import org.jooq.impl.QOM.UnmodifiableList;
|
||||
|
||||
@ -112,7 +109,7 @@ implements
|
||||
private transient DataType<?>[] types;
|
||||
|
||||
Values(Row[] rows) {
|
||||
this(rows, name("v"), fieldNamesC(degree(rows)));
|
||||
this(rows, name("v"), fieldAliases(degree(rows)));
|
||||
}
|
||||
|
||||
Values(Row[] rows, Name alias, Name[] fieldAliases) {
|
||||
@ -121,6 +118,15 @@ implements
|
||||
this.rows = assertNotEmpty(rows);
|
||||
}
|
||||
|
||||
private static Name[] fieldAliases(int degree) {
|
||||
Name[] result = new Name[degree];
|
||||
|
||||
for (int i = 0; i < result.length; i++)
|
||||
result[i] = name("c" + (i + 1));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static final int degree(Row[] rows) {
|
||||
return isEmpty(rows) ? 0 : rows[0].size();
|
||||
}
|
||||
@ -150,7 +156,7 @@ implements
|
||||
|
||||
@Override
|
||||
final FieldsImpl<R> fields0() {
|
||||
return new FieldsImpl<>(map(fieldAliases, (n, i) -> DSL.field(n, rows[0].dataType(i))));
|
||||
return new FieldsImpl<>(map(fieldAliases, (n, i) -> DSL.field(alias.append(n), rows[0].dataType(i))));
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user