[jOOQ/jOOQ#2370] [jOOQ/jOOQ#8528] Add org.jooq.TableOptions
... and interpret CREATE TEMPORARY TABLE .. ON COMMIT flags
This commit is contained in:
parent
4e0fedd5a4
commit
de6b977d51
@ -129,6 +129,11 @@ public interface Table<R extends Record> extends TableLike<R>, Named {
|
||||
*/
|
||||
TableType getType();
|
||||
|
||||
/**
|
||||
* Get the table options.
|
||||
*/
|
||||
TableOptions getOptions();
|
||||
|
||||
/**
|
||||
* The comment given to the table.
|
||||
* <p>
|
||||
|
||||
166
jOOQ/src/main/java/org/jooq/TableOptions.java
Normal file
166
jOOQ/src/main/java/org/jooq/TableOptions.java
Normal file
@ -0,0 +1,166 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* A description of various additional {@link Table} options to describe the
|
||||
* table runtime meta model.
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public final class TableOptions implements Serializable {
|
||||
|
||||
private final TableType type;
|
||||
private final OnCommit onCommit;
|
||||
private final Select<?> select;
|
||||
|
||||
private TableOptions(TableType type) {
|
||||
this.type = type;
|
||||
this.onCommit = null;
|
||||
this.select = null;
|
||||
}
|
||||
|
||||
private TableOptions(OnCommit onCommit) {
|
||||
this.type = TableType.TEMPORARY;
|
||||
this.onCommit = onCommit;
|
||||
this.select = null;
|
||||
}
|
||||
|
||||
private TableOptions(TableType type, Select<?> select) {
|
||||
this.type = type;
|
||||
this.onCommit = null;
|
||||
this.select = select;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link TableOptions} object for a {@link TableType#TABLE}.
|
||||
*/
|
||||
public static final TableOptions table() {
|
||||
return new TableOptions(TableType.TABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link TableOptions} object for a {@link TableType#TEMPORARY}.
|
||||
*/
|
||||
public static final TableOptions temporaryTable() {
|
||||
return new TableOptions(TableType.TEMPORARY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link TableOptions} object for a {@link TableType#TEMPORARY}.
|
||||
*/
|
||||
public static final TableOptions temporaryTable(OnCommit onCommit) {
|
||||
return new TableOptions(onCommit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link TableOptions} object for a {@link TableType#VIEW}.
|
||||
*/
|
||||
public static final TableOptions view(Select<?> select) {
|
||||
return new TableOptions(TableType.VIEW, select);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link TableOptions} object for a {@link TableType#MATERIALIZED_VIEW}.
|
||||
*/
|
||||
public static final TableOptions materializedView(Select<?> select) {
|
||||
return new TableOptions(TableType.MATERIALIZED_VIEW, select);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link TableOptions} object for a {@link TableType#EXPRESSION}.
|
||||
*/
|
||||
public static final TableOptions expression() {
|
||||
return new TableOptions(TableType.EXPRESSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link TableOptions} object for a {@link TableType#FUNCTION}.
|
||||
*/
|
||||
public static final TableOptions function() {
|
||||
return new TableOptions(TableType.FUNCTION);
|
||||
}
|
||||
|
||||
/**
|
||||
* The table type.
|
||||
* <p>
|
||||
* This is never <code>null</code>.
|
||||
*/
|
||||
public final TableType type() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>ON COMMIT</code> flag for {@link TableType#TEMPORARY} tables.
|
||||
* <p>
|
||||
* This may be <code>null</code>, if it is undefined, or unknown, or if the
|
||||
* table is not a {@link TableType#TEMPORARY} table.
|
||||
*/
|
||||
public final OnCommit onCommit() {
|
||||
return onCommit;
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>SELECT</code> statement defining this {@link TableType#VIEW} or
|
||||
* {@link TableType#MATERIALIZED_VIEW}.
|
||||
* <p>
|
||||
* This may be <code>null</code>, if it is undefined, or unknown, or if the
|
||||
* table is not a view.
|
||||
*/
|
||||
public final Select<?> select() {
|
||||
return select;
|
||||
}
|
||||
|
||||
public enum OnCommit {
|
||||
|
||||
@Support({ POSTGRES })
|
||||
DELETE_ROWS,
|
||||
|
||||
@Support({ POSTGRES })
|
||||
PRESERVE_ROWS,
|
||||
|
||||
@Support({ POSTGRES })
|
||||
DROP;
|
||||
}
|
||||
}
|
||||
@ -103,6 +103,7 @@ import org.jooq.TableField;
|
||||
import org.jooq.TableLike;
|
||||
import org.jooq.TableOnStep;
|
||||
import org.jooq.TableOptionalOnStep;
|
||||
import org.jooq.TableOptions;
|
||||
import org.jooq.TableOuterJoinStep;
|
||||
import org.jooq.TablePartitionByStep;
|
||||
import org.jooq.TableType;
|
||||
@ -121,22 +122,22 @@ abstract class AbstractTable<R extends Record> extends AbstractNamed implements
|
||||
private static final long serialVersionUID = 3155496238969274871L;
|
||||
private static final Clause[] CLAUSES = { TABLE };
|
||||
|
||||
private final TableType type;
|
||||
private final TableOptions options;
|
||||
private Schema tableschema;
|
||||
private transient DataType<R> tabletype;
|
||||
|
||||
AbstractTable(TableType type, Name name) {
|
||||
this(type, name, null, null);
|
||||
AbstractTable(TableOptions options, Name name) {
|
||||
this(options, name, null, null);
|
||||
}
|
||||
|
||||
AbstractTable(TableType type, Name name, Schema schema) {
|
||||
this(type, name, schema, null);
|
||||
AbstractTable(TableOptions options, Name name, Schema schema) {
|
||||
this(options, name, schema, null);
|
||||
}
|
||||
|
||||
AbstractTable(TableType type, Name name, Schema schema, Comment comment) {
|
||||
AbstractTable(TableOptions options, Name name, Schema schema, Comment comment) {
|
||||
super(qualify(schema, name), comment);
|
||||
|
||||
this.type = type;
|
||||
this.options = options;
|
||||
this.tableschema = schema;
|
||||
}
|
||||
|
||||
@ -393,7 +394,12 @@ abstract class AbstractTable<R extends Record> extends AbstractNamed implements
|
||||
|
||||
@Override
|
||||
public final TableType getType() {
|
||||
return type;
|
||||
return options.type();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final TableOptions getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -55,7 +55,7 @@ import org.jooq.Param;
|
||||
// ...
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableType;
|
||||
import org.jooq.TableOptions;
|
||||
import org.jooq.UDTRecord;
|
||||
import org.jooq.exception.DataTypeException;
|
||||
import org.jooq.util.h2.H2DataType;
|
||||
@ -87,7 +87,7 @@ final class ArrayTable extends AbstractTable<Record> {
|
||||
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
ArrayTable(Field<?> array, Name alias, Name[] fieldAliases) {
|
||||
super(TableType.EXPRESSION, alias);
|
||||
super(TableOptions.expression(), alias);
|
||||
|
||||
Class<?> arrayType;
|
||||
|
||||
@ -274,7 +274,7 @@ final class ArrayTable extends AbstractTable<Record> {
|
||||
private static final long serialVersionUID = 2662639259338694177L;
|
||||
|
||||
DialectArrayTable() {
|
||||
super(TableType.EXPRESSION, alias);
|
||||
super(TableOptions.expression(), alias);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -51,7 +51,7 @@ import org.jooq.Name;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Select;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableType;
|
||||
import org.jooq.TableOptions;
|
||||
|
||||
/**
|
||||
* Essentially, this is the same as <code>ArrayTable</code>, except that it simulates
|
||||
@ -82,7 +82,7 @@ final class ArrayTableEmulation extends AbstractTable<Record> {
|
||||
}
|
||||
|
||||
ArrayTableEmulation(Object[] array, Name alias, Name fieldAlias) {
|
||||
super(TableType.EXPRESSION, alias);
|
||||
super(TableOptions.expression(), alias);
|
||||
|
||||
this.array = array;
|
||||
this.alias = alias;
|
||||
|
||||
@ -48,7 +48,7 @@ import org.jooq.Name;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Select;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableType;
|
||||
import org.jooq.TableOptions;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
@ -65,7 +65,7 @@ final class CommonTableExpressionImpl<R extends Record> extends AbstractTable<R>
|
||||
private final Fields<R> fields;
|
||||
|
||||
CommonTableExpressionImpl(DerivedColumnListImpl name, Select<R> select) {
|
||||
super(TableType.EXPRESSION, name.name);
|
||||
super(TableOptions.expression(), name.name);
|
||||
|
||||
this.name = name;
|
||||
this.select = select;
|
||||
|
||||
@ -126,6 +126,7 @@ import org.jooq.SQL;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.Select;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableOptions.OnCommit;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
@ -183,6 +184,7 @@ final class CreateTableImpl extends AbstractRowCountQuery implements
|
||||
|
||||
final Table<?> $table() { return table; }
|
||||
final boolean $temporary() { return temporary; }
|
||||
final OnCommit $onCommit() { return onCommit; }
|
||||
final Select<?> $select() { return select; }
|
||||
final List<Field<?>> $columnFields() { return columnFields; }
|
||||
final List<DataType<?>> $columnTypes() { return columnTypes; }
|
||||
@ -690,10 +692,4 @@ final class CreateTableImpl extends AbstractRowCountQuery implements
|
||||
|
||||
|
||||
|
||||
|
||||
private enum OnCommit {
|
||||
DELETE_ROWS,
|
||||
PRESERVE_ROWS,
|
||||
DROP;
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,6 +55,7 @@ import java.util.List;
|
||||
|
||||
import org.jooq.Constraint;
|
||||
import org.jooq.CreateSequenceFlagsStep;
|
||||
import org.jooq.CreateTableOnCommitStep;
|
||||
import org.jooq.DDLExportConfiguration;
|
||||
import org.jooq.DDLFlag;
|
||||
import org.jooq.DSLContext;
|
||||
@ -68,6 +69,7 @@ import org.jooq.Query;
|
||||
import org.jooq.Schema;
|
||||
import org.jooq.Sequence;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableOptions.OnCommit;
|
||||
import org.jooq.TableType;
|
||||
import org.jooq.UniqueKey;
|
||||
import org.jooq.tools.StringUtils;
|
||||
@ -86,15 +88,33 @@ final class DDL {
|
||||
}
|
||||
|
||||
private final Query createTable(Table<?> table, Collection<? extends Constraint> constraints) {
|
||||
return (configuration.createTableIfNotExists()
|
||||
? table.getType() == TableType.TEMPORARY
|
||||
boolean temporary = table.getType() == TableType.TEMPORARY;
|
||||
OnCommit onCommit = table.getOptions().onCommit();
|
||||
|
||||
CreateTableOnCommitStep s0 = (configuration.createTableIfNotExists()
|
||||
? temporary
|
||||
? ctx.createTemporaryTableIfNotExists(table)
|
||||
: ctx.createTableIfNotExists(table)
|
||||
: table.getType() == TableType.TEMPORARY
|
||||
: temporary
|
||||
? ctx.createTemporaryTable(table)
|
||||
: ctx.createTable(table))
|
||||
.columns(sortIf(Arrays.asList(table.fields()), !configuration.respectColumnOrder()))
|
||||
.constraints(constraints);
|
||||
.columns(sortIf(Arrays.asList(table.fields()), !configuration.respectColumnOrder()))
|
||||
.constraints(constraints);
|
||||
|
||||
if (temporary && onCommit != null) {
|
||||
switch (table.getOptions().onCommit()) {
|
||||
case DELETE_ROWS:
|
||||
return s0.onCommitDeleteRows();
|
||||
case PRESERVE_ROWS:
|
||||
return s0.onCommitPreserveRows();
|
||||
case DROP:
|
||||
return s0.onCommitDrop();
|
||||
default:
|
||||
throw new IllegalStateException("Unsupported flag: " + onCommit);
|
||||
}
|
||||
}
|
||||
|
||||
return s0;
|
||||
}
|
||||
|
||||
final Query createSequence(Sequence<?> sequence) {
|
||||
|
||||
@ -75,6 +75,7 @@ import org.jooq.SortField;
|
||||
import org.jooq.SortOrder;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableField;
|
||||
import org.jooq.TableOptions;
|
||||
import org.jooq.TableType;
|
||||
import org.jooq.UniqueKey;
|
||||
import org.jooq.exception.DataAccessException;
|
||||
@ -225,7 +226,6 @@ final class DDLInterpreter {
|
||||
|
||||
private final void accept0(CreateTableImpl query) {
|
||||
Table<?> table = query.$table();
|
||||
boolean temporary = query.$temporary();
|
||||
MutableSchema schema = getSchema(table.getSchema(), true);
|
||||
|
||||
// TODO We're doing this all the time. Can this be factored out without adding too much abstraction?
|
||||
@ -237,7 +237,7 @@ final class DDLInterpreter {
|
||||
return;
|
||||
}
|
||||
|
||||
MutableTable mt = newTable(table, schema, query.$columnFields(), query.$columnTypes(), query.$select(), query.$comment(), temporary ? TableType.TEMPORARY : TableType.TABLE);
|
||||
MutableTable mt = newTable(table, schema, query.$columnFields(), query.$columnTypes(), query.$select(), query.$comment(), query.$temporary() ? TableOptions.temporaryTable(query.$onCommit()) : TableOptions.table());
|
||||
|
||||
for (Constraint constraint : query.$constraints()) {
|
||||
ConstraintImpl impl = (ConstraintImpl) constraint;
|
||||
@ -380,7 +380,7 @@ final class DDLInterpreter {
|
||||
|
||||
return;
|
||||
}
|
||||
else if (!table(existing.type))
|
||||
else if (!table(existing))
|
||||
throw objectNotTable(table);
|
||||
|
||||
// TODO: Multi-add statements
|
||||
@ -542,9 +542,9 @@ final class DDLInterpreter {
|
||||
|
||||
return;
|
||||
}
|
||||
else if (!table(existing.type))
|
||||
else if (!table(existing))
|
||||
throw objectNotTable(table);
|
||||
else if (query.$temporary() && existing.type != TableType.TEMPORARY)
|
||||
else if (query.$temporary() && existing.options.type() != TableType.TEMPORARY)
|
||||
throw objectNotTemporaryTable(table);
|
||||
|
||||
drop(schema.tables, existing, query.$cascade());
|
||||
@ -556,7 +556,7 @@ final class DDLInterpreter {
|
||||
|
||||
MutableTable existing = schema.table(table);
|
||||
if (existing != null) {
|
||||
if (!view(existing.type))
|
||||
if (!view(existing))
|
||||
throw objectNotView(table);
|
||||
else if (query.$orReplace())
|
||||
drop(schema.tables, existing, RESTRICT);
|
||||
@ -570,7 +570,7 @@ final class DDLInterpreter {
|
||||
for (Field<?> f : query.$select().getSelect())
|
||||
columnTypes.add(f.getDataType());
|
||||
|
||||
newTable(table, schema, Arrays.asList(query.$fields()), columnTypes, query.$select(), null, TableType.VIEW);
|
||||
newTable(table, schema, Arrays.asList(query.$fields()), columnTypes, query.$select(), null, TableOptions.view(query.$select()));
|
||||
}
|
||||
|
||||
private final void accept0(AlterViewImpl query) {
|
||||
@ -584,7 +584,7 @@ final class DDLInterpreter {
|
||||
|
||||
return;
|
||||
}
|
||||
else if (!view(existing.type))
|
||||
else if (!view(existing))
|
||||
throw objectNotView(table);
|
||||
|
||||
Table<?> renameTo = query.$renameTo();
|
||||
@ -605,7 +605,7 @@ final class DDLInterpreter {
|
||||
|
||||
return;
|
||||
}
|
||||
else if (!view(existing.type))
|
||||
else if (!view(existing))
|
||||
throw objectNotView(table);
|
||||
|
||||
drop(schema.tables, existing, RESTRICT);
|
||||
@ -827,11 +827,13 @@ final class DDLInterpreter {
|
||||
// Auxiliary methods
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
private static final boolean view(TableType type) {
|
||||
private static final boolean view(MutableTable mt) {
|
||||
TableType type = mt.options.type();
|
||||
return type == TableType.VIEW || type == TableType.MATERIALIZED_VIEW;
|
||||
}
|
||||
|
||||
private static final boolean table(TableType type) {
|
||||
private static final boolean table(MutableTable mt) {
|
||||
TableType type = mt.options.type();
|
||||
return type == TableType.TABLE || type == TableType.TEMPORARY;
|
||||
}
|
||||
|
||||
@ -881,9 +883,9 @@ final class DDLInterpreter {
|
||||
List<DataType<?>> columnTypes,
|
||||
Select<?> select,
|
||||
Comment comment,
|
||||
TableType type
|
||||
TableOptions options
|
||||
) {
|
||||
MutableTable t = new MutableTable((UnqualifiedName) table.getUnqualifiedName(), schema, comment, type);
|
||||
MutableTable t = new MutableTable((UnqualifiedName) table.getUnqualifiedName(), schema, comment, options);
|
||||
|
||||
if (!columns.isEmpty()) {
|
||||
for (int i = 0; i < columns.size(); i++) {
|
||||
@ -954,7 +956,7 @@ final class DDLInterpreter {
|
||||
}
|
||||
|
||||
private static final DataDefinitionException alreadyExists(Table<?> t, MutableTable mt) {
|
||||
if (view(mt.type))
|
||||
if (view(mt))
|
||||
return viewAlreadyExists(t);
|
||||
else
|
||||
return tableAlreadyExists(t);
|
||||
@ -1122,13 +1124,13 @@ final class DDLInterpreter {
|
||||
List<MutableUniqueKey> uniqueKeys = new ArrayList<>();
|
||||
List<MutableForeignKey> foreignkeys = new ArrayList<>();
|
||||
List<MutableIndex> indexes = new ArrayList<>();
|
||||
TableType type;
|
||||
TableOptions options;
|
||||
|
||||
MutableTable(UnqualifiedName name, MutableSchema schema, Comment comment, TableType type) {
|
||||
MutableTable(UnqualifiedName name, MutableSchema schema, Comment comment, TableOptions options) {
|
||||
super(name, comment);
|
||||
|
||||
this.schema = schema;
|
||||
this.type = type;
|
||||
this.options = options;
|
||||
schema.tables.add(this);
|
||||
}
|
||||
|
||||
@ -1212,7 +1214,7 @@ final class DDLInterpreter {
|
||||
|
||||
private final class InterpretedTable extends TableImpl<Record> {
|
||||
InterpretedTable(MutableSchema.InterpretedSchema schema) {
|
||||
super(MutableTable.this.name, schema, null, null, null, null, MutableTable.this.comment, MutableTable.this.type);
|
||||
super(MutableTable.this.name, schema, null, null, null, null, MutableTable.this.comment, MutableTable.this.options);
|
||||
|
||||
for (MutableField field : MutableTable.this.fields)
|
||||
createField(field.name, field.type, field.comment != null ? field.comment.getComment() : null);
|
||||
|
||||
@ -38,7 +38,6 @@
|
||||
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.TableType.EXPRESSION;
|
||||
import static org.jooq.impl.Names.N_SELECT;
|
||||
|
||||
import org.jooq.Clause;
|
||||
@ -47,6 +46,7 @@ import org.jooq.Name;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Select;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableOptions;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
@ -58,7 +58,7 @@ final class DerivedTable<R extends Record> extends AbstractTable<R> {
|
||||
private final Select<R> query;
|
||||
|
||||
DerivedTable(Select<R> query) {
|
||||
super(EXPRESSION, N_SELECT);
|
||||
super(TableOptions.expression(), N_SELECT);
|
||||
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
@ -38,7 +38,6 @@
|
||||
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.TableType.EXPRESSION;
|
||||
import static org.jooq.impl.DSL.inline;
|
||||
import static org.jooq.impl.DSL.select;
|
||||
import static org.jooq.impl.Names.N_DUAL;
|
||||
@ -50,6 +49,7 @@ import org.jooq.Name;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Schema;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableOptions;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
@ -85,7 +85,7 @@ final class Dual extends AbstractTable<Record> {
|
||||
}
|
||||
|
||||
Dual(boolean force) {
|
||||
super(EXPRESSION, N_DUAL, (Schema) null);
|
||||
super(TableOptions.expression(), N_DUAL, (Schema) null);
|
||||
|
||||
this.force = force;
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ implements VersionsBetweenAndStep<R, T> {
|
||||
private QueryPart maxvalue;
|
||||
|
||||
FlashbackTable(Table<R> table, Field<?> asOf, QueryPart minvalue, FlashbackType type) {
|
||||
super(table.getType(), N_FLASHBACK);
|
||||
super(table.getOptions(), N_FLASHBACK);
|
||||
|
||||
this.table = table;
|
||||
this.asOf = asOf;
|
||||
|
||||
@ -37,7 +37,6 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.TableType.FUNCTION;
|
||||
import static org.jooq.impl.Keywords.K_TABLE;
|
||||
import static org.jooq.impl.Names.N_FUNCTION;
|
||||
|
||||
@ -46,6 +45,7 @@ import org.jooq.Field;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableOptions;
|
||||
import org.jooq.exception.SQLDialectNotSupportedException;
|
||||
|
||||
/**
|
||||
@ -61,7 +61,7 @@ final class FunctionTable<R extends Record> extends AbstractTable<R> {
|
||||
private final Field<?> function;
|
||||
|
||||
FunctionTable(Field<?> function) {
|
||||
super(FUNCTION, N_FUNCTION);
|
||||
super(TableOptions.function(), N_FUNCTION);
|
||||
|
||||
this.function = function;
|
||||
}
|
||||
|
||||
@ -37,7 +37,6 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.TableType.EXPRESSION;
|
||||
import static org.jooq.impl.DSL.level;
|
||||
import static org.jooq.impl.DSL.name;
|
||||
import static org.jooq.impl.DSL.one;
|
||||
@ -52,6 +51,7 @@ import org.jooq.Name;
|
||||
import org.jooq.QueryPart;
|
||||
import org.jooq.Record1;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableOptions;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
@ -72,7 +72,7 @@ final class GenerateSeries extends AbstractTable<Record1<Integer>> {
|
||||
}
|
||||
|
||||
GenerateSeries(Field<Integer> from, Field<Integer> to, Field<Integer> step) {
|
||||
super(EXPRESSION, N_GENERATE_SERIES);
|
||||
super(TableOptions.expression(), N_GENERATE_SERIES);
|
||||
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
|
||||
@ -70,7 +70,7 @@ final class HintedTable<R extends Record> extends AbstractTable<R> {
|
||||
}
|
||||
|
||||
HintedTable(AbstractTable<R> delegate, Keyword keywords, QueryPartList<Name> arguments) {
|
||||
super(delegate.getType(), delegate.getQualifiedName(), delegate.getSchema());
|
||||
super(delegate.getOptions(), delegate.getQualifiedName(), delegate.getSchema());
|
||||
|
||||
this.delegate = delegate;
|
||||
this.keywords = keywords;
|
||||
|
||||
@ -85,7 +85,6 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.TableType.EXPRESSION;
|
||||
import static org.jooq.impl.DSL.condition;
|
||||
import static org.jooq.impl.DSL.exists;
|
||||
import static org.jooq.impl.DSL.notExists;
|
||||
@ -126,6 +125,7 @@ import org.jooq.TableField;
|
||||
import org.jooq.TableLike;
|
||||
import org.jooq.TableOnConditionStep;
|
||||
import org.jooq.TableOptionalOnStep;
|
||||
import org.jooq.TableOptions;
|
||||
import org.jooq.TableOuterJoinStep;
|
||||
import org.jooq.TablePartitionByStep;
|
||||
import org.jooq.conf.RenderOptionalKeyword;
|
||||
@ -177,7 +177,7 @@ implements
|
||||
|
||||
|
||||
|
||||
super(EXPRESSION, N_JOIN);
|
||||
super(TableOptions.expression(), N_JOIN);
|
||||
|
||||
this.lhs = lhs.asTable();
|
||||
this.rhs = rhs.asTable();
|
||||
|
||||
@ -43,7 +43,7 @@ import org.jooq.Context;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableType;
|
||||
import org.jooq.TableOptions;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
@ -57,7 +57,7 @@ final class Lateral<R extends Record> extends AbstractTable<R> {
|
||||
private final Table<R> table;
|
||||
|
||||
Lateral(Table<R> table) {
|
||||
super(TableType.EXPRESSION, table.getQualifiedName(), table.getSchema());
|
||||
super(TableOptions.expression(), table.getQualifiedName(), table.getSchema());
|
||||
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
@ -37,7 +37,6 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.TableType.EXPRESSION;
|
||||
|
||||
|
||||
|
||||
|
||||
@ -37,7 +37,6 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.TableType.EXPRESSION;
|
||||
import static org.jooq.impl.Keywords.K_ROWS_FROM;
|
||||
import static org.jooq.impl.Names.N_ROWSFROM;
|
||||
|
||||
@ -50,6 +49,7 @@ import org.jooq.Field;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableOptions;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
@ -64,7 +64,7 @@ final class RowsFrom extends AbstractTable<Record> {
|
||||
private final TableList tables;
|
||||
|
||||
RowsFrom(Table<?>... tables) {
|
||||
super(EXPRESSION, N_ROWSFROM);
|
||||
super(TableOptions.expression(), N_ROWSFROM);
|
||||
|
||||
this.tables = new TableList(Arrays.asList(tables));
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ import org.jooq.Name;
|
||||
import org.jooq.QueryPart;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableType;
|
||||
import org.jooq.TableOptions;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
@ -54,7 +54,7 @@ final class SQLTable extends AbstractTable<Record> {
|
||||
private final QueryPart delegate;
|
||||
|
||||
SQLTable(QueryPart delegate) {
|
||||
super(TableType.EXPRESSION, DSL.name(delegate.toString()));
|
||||
super(TableOptions.expression(), DSL.name(delegate.toString()));
|
||||
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ final class TableAlias<R extends Record> extends AbstractTable<R> {
|
||||
}
|
||||
|
||||
TableAlias(Table<R> table, Name alias, Name[] fieldAliases, boolean wrapInParentheses) {
|
||||
super(table.getType(), alias, table.getSchema());
|
||||
super(table.getOptions(), alias, table.getSchema());
|
||||
|
||||
this.alias = new Alias<>(table, this, alias, fieldAliases, wrapInParentheses);
|
||||
this.aliasedFields = init(fieldAliases);
|
||||
|
||||
@ -62,7 +62,7 @@ import org.jooq.Row;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.Schema;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableType;
|
||||
import org.jooq.TableOptions;
|
||||
import org.jooq.tools.StringUtils;
|
||||
|
||||
/**
|
||||
@ -165,11 +165,11 @@ public class TableImpl<R extends Record> extends AbstractTable<R> {
|
||||
}
|
||||
|
||||
public TableImpl(Name name, Schema schema, Table<?> child, ForeignKey<?, R> path, Table<R> aliased, Field<?>[] parameters, Comment comment) {
|
||||
this(name, schema, child, path, aliased, parameters, comment, TableType.TABLE);
|
||||
this(name, schema, child, path, aliased, parameters, comment, TableOptions.table());
|
||||
}
|
||||
|
||||
public TableImpl(Name name, Schema schema, Table<?> child, ForeignKey<?, R> path, Table<R> aliased, Field<?>[] parameters, Comment comment, TableType type) {
|
||||
super(type, name, schema, comment);
|
||||
public TableImpl(Name name, Schema schema, Table<?> child, ForeignKey<?, R> path, Table<R> aliased, Field<?>[] parameters, Comment comment, TableOptions options) {
|
||||
super(options, name, schema, comment);
|
||||
|
||||
this.fields = new Fields<>();
|
||||
this.child = child;
|
||||
|
||||
@ -39,7 +39,6 @@ package org.jooq.impl;
|
||||
|
||||
import static org.jooq.Clause.TABLE_VALUES;
|
||||
// ...
|
||||
import static org.jooq.TableType.EXPRESSION;
|
||||
import static org.jooq.impl.Keywords.K_MULTISET;
|
||||
import static org.jooq.impl.Keywords.K_TABLE;
|
||||
import static org.jooq.impl.Keywords.K_VALUES;
|
||||
@ -51,6 +50,7 @@ import org.jooq.Record;
|
||||
import org.jooq.Row;
|
||||
import org.jooq.Select;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableOptions;
|
||||
|
||||
/**
|
||||
* An implementation for the <code>VALUES(...)</code> table constructor
|
||||
@ -67,7 +67,7 @@ final class Values<R extends Record> extends AbstractTable<R> {
|
||||
private final Row[] rows;
|
||||
|
||||
Values(Row[] rows) {
|
||||
super(EXPRESSION, N_VALUES);
|
||||
super(TableOptions.expression(), N_VALUES);
|
||||
|
||||
this.rows = assertNotEmpty(rows);
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ final class WithTable<R extends Record> extends AbstractTable<R> {
|
||||
private final String hint;
|
||||
|
||||
WithTable(AbstractTable<R> delegate, String hint) {
|
||||
super(delegate.getType(), delegate.getQualifiedName(), delegate.getSchema());
|
||||
super(delegate.getOptions(), delegate.getQualifiedName(), delegate.getSchema());
|
||||
|
||||
this.delegate = delegate;
|
||||
this.hint = hint;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user