[jOOQ/jOOQ#13553] Add TableLike<R>.asMultiset(): Field<Result<R>>
This includes: - [jOOQ/jOOQ#13552] Change DSL.multiset(Select<R>) into DSL.multiset(TableLike<R>)
This commit is contained in:
parent
7f416b3136
commit
e122273e50
@ -37,10 +37,27 @@
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.H2;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
import static org.jooq.impl.DSL.selectFrom;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@ -60,6 +77,14 @@ extends
|
||||
Table */
|
||||
{
|
||||
|
||||
/**
|
||||
* Turn this {@link TableLike} expression into a
|
||||
* {@link DSL#multiset(TableLike)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
Field<Result<R>> asMultiset();
|
||||
|
||||
/**
|
||||
* The underlying table representation of this object.
|
||||
* <p>
|
||||
|
||||
@ -102,6 +102,7 @@ import org.jooq.QualifiedAsterisk;
|
||||
import org.jooq.QueryPart;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.RecordType;
|
||||
import org.jooq.Result;
|
||||
import org.jooq.Row;
|
||||
import org.jooq.RowId;
|
||||
import org.jooq.SQL;
|
||||
@ -301,6 +302,11 @@ abstract class AbstractTable<R extends Record> extends AbstractNamed implements
|
||||
return fieldsRow().fields();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<Result<R>> asMultiset() {
|
||||
return DSL.multiset(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Table<R> asTable() {
|
||||
return this;
|
||||
|
||||
@ -25624,8 +25624,8 @@ public class DSL {
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static <R extends Record> Field<Result<R>> multiset(Select<R> select) {
|
||||
return new Multiset<>(select);
|
||||
public static <R extends Record> Field<Result<R>> multiset(TableLike<R> table) {
|
||||
return new Multiset<>(table);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@ -105,6 +105,7 @@ import org.jooq.SQLDialect;
|
||||
import org.jooq.Scope;
|
||||
import org.jooq.Select;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableLike;
|
||||
// ...
|
||||
import org.jooq.XML;
|
||||
import org.jooq.XMLAggOrderByStep;
|
||||
@ -119,13 +120,19 @@ final class Multiset<R extends Record> extends AbstractField<Result<R>> implemen
|
||||
static final Set<SQLDialect> NO_SUPPORT_XML_COMPARE = SQLDialect.supportedBy(POSTGRES);
|
||||
static final Set<SQLDialect> FORCE_LIMIT_IN_DERIVED_TABLE = SQLDialect.supportedBy(MARIADB, MYSQL);
|
||||
|
||||
final TableLike<R> table;
|
||||
final Select<R> select;
|
||||
|
||||
Multiset(TableLike<R> table) {
|
||||
this(table, table instanceof Select ? (Select<R>) table : selectFrom(table));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Multiset(Select<R> select) {
|
||||
private Multiset(TableLike<R> table, Select<R> select) {
|
||||
// [#12100] Can't use select.fieldsRow() here.
|
||||
super(N_MULTISET, new MultisetDataType<>((AbstractRow<R>) DSL.row(select.getSelect()), select.getRecordType()));
|
||||
|
||||
this.table = table;
|
||||
this.select = select;
|
||||
}
|
||||
|
||||
@ -448,8 +455,8 @@ final class Multiset<R extends Record> extends AbstractField<Result<R>> implemen
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final Select<R> $select() {
|
||||
return select;
|
||||
public final TableLike<R> $table() {
|
||||
return table;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -118,6 +118,7 @@ import org.jooq.Spatial;
|
||||
import org.jooq.Statement;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableElement;
|
||||
import org.jooq.TableLike;
|
||||
// ...
|
||||
// ...
|
||||
import org.jooq.WindowDefinition;
|
||||
@ -855,7 +856,7 @@ public final class QOM {
|
||||
/*permits
|
||||
Multiset*/
|
||||
{
|
||||
@NotNull Select<R> $select();
|
||||
@NotNull TableLike<R> $table();
|
||||
}
|
||||
|
||||
public /*sealed*/ interface ScalarSubquery<T>
|
||||
|
||||
@ -2866,6 +2866,11 @@ implements
|
||||
return getDelegate().fetchMany();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<Result<R>> asMultiset() {
|
||||
return getDelegate().asMultiset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Table<R> asTable() {
|
||||
return getDelegate().asTable();
|
||||
|
||||
@ -265,6 +265,7 @@ import org.jooq.QualifiedAsterisk;
|
||||
import org.jooq.QueryPart;
|
||||
import org.jooq.Record;
|
||||
// ...
|
||||
import org.jooq.Result;
|
||||
import org.jooq.Row;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.Scope;
|
||||
@ -656,6 +657,11 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
return asTable().fieldsRow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<Result<R>> asMultiset() {
|
||||
return DSL.multiset(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Table<R> asTable() {
|
||||
// [#13349] Delay the possibly expensive computation of the auto alias,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user