[jOOQ/jOOQ#13461] ResultQueryTrait::getFields should accept Supplier<ResultSetMetaData> instead of ResultSetMetaData
This commit is contained in:
parent
551b8576e1
commit
b87e1d360b
@ -1320,7 +1320,7 @@ abstract class AbstractDMLQuery<R extends Record> extends AbstractRowCountQuery
|
||||
: Tools.findAny(returningResolvedAsterisks, f -> f.getDataType().identity());
|
||||
}
|
||||
|
||||
public final Field<?>[] getFields(ResultSetMetaData rs) throws SQLException {
|
||||
public final Field<?>[] getFields(ThrowingSupplier<? extends ResultSetMetaData, SQLException> rs) throws SQLException {
|
||||
return returningResolvedAsterisks.toArray(EMPTY_FIELD);
|
||||
}
|
||||
|
||||
|
||||
@ -258,7 +258,7 @@ implements
|
||||
ctx.resultSet(new MockResultSet(r));
|
||||
}
|
||||
|
||||
Field<?>[] fields = getFields(ctx.resultSet().getMetaData());
|
||||
Field<?>[] fields = getFields(() -> ctx.resultSet().getMetaData());
|
||||
cursor = new CursorImpl<>(ctx, listener, fields, intern.internIndexes(fields), keepStatement(), keepResultSet(), getRecordType(), SettingsTools.getMaxRows(maxRows, ctx.settings()), autoclosing);
|
||||
|
||||
if (!lazy) {
|
||||
|
||||
@ -104,7 +104,7 @@ implements
|
||||
// TODO: Refactor this coercion, share logic with AbstractResultQuery
|
||||
|
||||
@Override
|
||||
public final Field<?>[] getFields(ResultSetMetaData rs) throws SQLException {
|
||||
public final Field<?>[] getFields(ThrowingSupplier<? extends ResultSetMetaData, SQLException> rs) throws SQLException {
|
||||
Field<?>[] f = getFields();
|
||||
return f != null ? f : delegate.getFields(rs);
|
||||
}
|
||||
|
||||
@ -303,7 +303,7 @@ final class R2DBC {
|
||||
r.map((row, meta) -> {
|
||||
try {
|
||||
// TODO: Cache this getFields() call
|
||||
Field<?>[] fields = query.getFields(new R2DBCResultSetMetaData(query.configuration(), meta));
|
||||
Field<?>[] fields = query.getFields(() -> new R2DBCResultSetMetaData(query.configuration(), meta));
|
||||
|
||||
// TODO: This call is duplicated from CursorImpl and related classes.
|
||||
// Refactor this call to make sure code is re-used, especially when
|
||||
|
||||
@ -1578,7 +1578,7 @@ extends
|
||||
* @throws SQLException If something goes wrong when accessing
|
||||
* {@link ResultSetMetaData}.
|
||||
*/
|
||||
default Field<?>[] getFields(ResultSetMetaData rs) throws SQLException {
|
||||
default Field<?>[] getFields(ThrowingSupplier<? extends ResultSetMetaData, SQLException> rs) throws SQLException {
|
||||
return getFields();
|
||||
}
|
||||
|
||||
|
||||
@ -41,6 +41,7 @@ import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
import static org.jooq.impl.Tools.isEmpty;
|
||||
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.jooq.Clause;
|
||||
@ -102,13 +103,13 @@ final class SQLResultQuery extends AbstractResultQuery<Record> implements UEmpty
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<?>[] getFields(ResultSetMetaData meta) {
|
||||
public final Field<?>[] getFields(ThrowingSupplier<? extends ResultSetMetaData, SQLException> rs) throws SQLException {
|
||||
Field<?>[] result = getFields();
|
||||
|
||||
if (!isEmpty(result))
|
||||
return result;
|
||||
else
|
||||
return new MetaDataFieldProvider(configuration(), meta).getFields();
|
||||
return new MetaDataFieldProvider(configuration(), rs.get()).getFields();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -3365,7 +3365,7 @@ implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<?>[] getFields(ResultSetMetaData rs) throws SQLException {
|
||||
public final Field<?>[] getFields(ThrowingSupplier<? extends ResultSetMetaData, SQLException> rs) throws SQLException {
|
||||
return getDelegate().getFields(rs);
|
||||
}
|
||||
|
||||
|
||||
@ -226,6 +226,7 @@ import static org.jooq.impl.Transformations.transformQualify;
|
||||
import static org.jooq.impl.Transformations.transformRownum;
|
||||
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -714,13 +715,13 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<?>[] getFields(ResultSetMetaData meta) {
|
||||
public final Field<?>[] getFields(ThrowingSupplier<? extends ResultSetMetaData, SQLException> rs) throws SQLException {
|
||||
Field<?>[] fields = getFields();
|
||||
|
||||
// If no projection was specified explicitly, create fields from result
|
||||
// set meta data instead. This is typically the case for SELECT * ...
|
||||
if (fields.length == 0)
|
||||
return new MetaDataFieldProvider(configuration(), meta).getFields();
|
||||
return new MetaDataFieldProvider(configuration(), rs.get()).getFields();
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user