[jOOQ/jOOQ#5306] Support the standard SQL <data change delta table>
This commit is contained in:
parent
e22457cbf3
commit
c6d4705f72
@ -10899,7 +10899,7 @@ public class DSL {
|
||||
* {@link Delete} statement was applied.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ H2 })
|
||||
public static <R extends Record> Table<R> oldTable(Update<R> query) {
|
||||
return new DataChangeDeltaTable<>(ResultOption.OLD, query);
|
||||
}
|
||||
@ -10921,7 +10921,7 @@ public class DSL {
|
||||
* {@link Delete} statement was applied.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ H2 })
|
||||
public static <R extends Record> Table<R> oldTable(Merge<R> query) {
|
||||
return new DataChangeDeltaTable<>(ResultOption.OLD, query);
|
||||
}
|
||||
@ -10931,10 +10931,11 @@ public class DSL {
|
||||
* retrieve the modified data from after the {@link Update} or
|
||||
* {@link Insert} statement was applied.
|
||||
* <p>
|
||||
* This does not include trigger generated values.
|
||||
* Depending on the dialect, this may show transitive data prior to
|
||||
* referential integrity validation and the firing of any after triggers.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ H2 })
|
||||
public static <R extends Record> Table<R> newTable(Insert<R> query) {
|
||||
return new DataChangeDeltaTable<R>(ResultOption.NEW, query);
|
||||
}
|
||||
@ -10944,10 +10945,11 @@ public class DSL {
|
||||
* retrieve the modified data from after the {@link Update} or
|
||||
* {@link Insert} statement was applied.
|
||||
* <p>
|
||||
* This does not include trigger generated values.
|
||||
* Depending on the dialect, this may show transitive data prior to
|
||||
* referential integrity validation and the firing of any after triggers.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ H2 })
|
||||
public static <R extends Record> Table<R> newTable(Update<R> query) {
|
||||
return new DataChangeDeltaTable<R>(ResultOption.NEW, query);
|
||||
}
|
||||
@ -10957,10 +10959,11 @@ public class DSL {
|
||||
* retrieve the modified data from after the {@link Update} or
|
||||
* {@link Insert} statement was applied.
|
||||
* <p>
|
||||
* This does not include trigger generated values.
|
||||
* Depending on the dialect, this may show transitive data prior to
|
||||
* referential integrity validation and the firing of any after triggers.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ H2 })
|
||||
public static <R extends Record> Table<R> newTable(Merge<R> query) {
|
||||
return new DataChangeDeltaTable<R>(ResultOption.NEW, query);
|
||||
}
|
||||
@ -10970,7 +10973,10 @@ public class DSL {
|
||||
* retrieve the modified data from after the {@link Update} or
|
||||
* {@link Insert} statement was applied.
|
||||
* <p>
|
||||
* This includes trigger generated values.
|
||||
* Depending on the dialect, this may show data after all referential
|
||||
* integrity validation and all triggers have been executed or fired,
|
||||
* meaning there will be no more additional modification to the "final"
|
||||
* version of the modified data.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES })
|
||||
@ -10983,7 +10989,10 @@ public class DSL {
|
||||
* retrieve the modified data from after the {@link Update} or
|
||||
* {@link Insert} statement was applied.
|
||||
* <p>
|
||||
* This includes trigger generated values.
|
||||
* Depending on the dialect, this may show data after all referential
|
||||
* integrity validation and all triggers have been executed or fired,
|
||||
* meaning there will be no more additional modification to the "final"
|
||||
* version of the modified data.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES })
|
||||
@ -10996,10 +11005,13 @@ public class DSL {
|
||||
* retrieve the modified data from after the {@link Update} or
|
||||
* {@link Insert} statement was applied.
|
||||
* <p>
|
||||
* This includes trigger generated values.
|
||||
* Depending on the dialect, this may show data after all referential
|
||||
* integrity validation and all triggers have been executed or fired,
|
||||
* meaning there will be no more additional modification to the "final"
|
||||
* version of the modified data.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ H2 })
|
||||
public static <R extends Record> Table<R> finalTable(Merge<R> query) {
|
||||
return new DataChangeDeltaTable<>(ResultOption.FINAL, query);
|
||||
}
|
||||
|
||||
@ -50,7 +50,9 @@ import org.jooq.DMLQuery;
|
||||
import org.jooq.Delete;
|
||||
import org.jooq.Insert;
|
||||
import org.jooq.Merge;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Record1;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableOptions;
|
||||
import org.jooq.Update;
|
||||
@ -59,18 +61,28 @@ import org.jooq.Update;
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class DataChangeDeltaTable<R extends Record> extends AbstractTable<R> {
|
||||
final class DataChangeDeltaTable<R extends Record> extends AbstractTable<R> implements AutoAliasTable<R> {
|
||||
|
||||
private final ResultOption result;
|
||||
private final DMLQuery<R> query;
|
||||
private final Table<R> table;
|
||||
private final Name alias;
|
||||
|
||||
DataChangeDeltaTable(ResultOption result, DMLQuery<R> query) {
|
||||
super(TableOptions.expression(), table(query).getUnqualifiedName());
|
||||
this(result, query, table(query));
|
||||
}
|
||||
|
||||
private DataChangeDeltaTable(ResultOption result, DMLQuery<R> query, Table<R> table) {
|
||||
this(result, query, table, table.getUnqualifiedName());
|
||||
}
|
||||
|
||||
private DataChangeDeltaTable(ResultOption result, DMLQuery<R> query, Table<R> table, Name alias) {
|
||||
super(TableOptions.expression(), alias);
|
||||
|
||||
this.result = result;
|
||||
this.query = query;
|
||||
this.table = table(query);
|
||||
this.table = table;
|
||||
this.alias = alias;
|
||||
}
|
||||
|
||||
enum ResultOption {
|
||||
@ -110,6 +122,21 @@ final class DataChangeDeltaTable<R extends Record> extends AbstractTable<R> {
|
||||
// XXX: Table API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Table<R> as(Name as) {
|
||||
return new TableAlias<>(new DataChangeDeltaTable<>(result, query, table, as), as);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Table<R> as(Name as, Name... fieldAliases) {
|
||||
return new TableAlias<>(new DataChangeDeltaTable<>(result, query, table, as), as, fieldAliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Table<R> autoAlias(Context<?> ctx) {
|
||||
return as(alias);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Class<? extends R> getRecordType() {
|
||||
return table.getRecordType();
|
||||
@ -118,6 +145,6 @@ final class DataChangeDeltaTable<R extends Record> extends AbstractTable<R> {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
final FieldsImpl<R> fields0() {
|
||||
return ((AbstractRow<R>) table.fieldsRow()).fields;
|
||||
return ((AbstractRow<R>) table.as(alias).fieldsRow()).fields;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user