[#3077] Let Sequence implement QueryPart
This commit is contained in:
parent
2db3ea0308
commit
f0be59d1be
@ -52,14 +52,12 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* A type representing sequences in databases that support this.
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface Sequence<T extends Number> extends Serializable {
|
||||
public interface Sequence<T extends Number> extends QueryPart {
|
||||
|
||||
/**
|
||||
* Get the sequence name
|
||||
|
||||
@ -46,7 +46,10 @@ import static org.jooq.SQLDialect.FIREBIRD;
|
||||
import static org.jooq.impl.DSL.field;
|
||||
import static org.jooq.impl.DSL.select;
|
||||
|
||||
import org.jooq.BindContext;
|
||||
import org.jooq.Clause;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.DataType;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.RenderContext;
|
||||
@ -62,7 +65,7 @@ import org.jooq.exception.SQLDialectNotSupportedException;
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public class SequenceImpl<T extends Number> implements Sequence<T> {
|
||||
public class SequenceImpl<T extends Number> extends AbstractQueryPart implements Sequence<T> {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
@ -197,18 +200,35 @@ public class SequenceImpl<T extends Number> implements Sequence<T> {
|
||||
|
||||
private final String getQualifiedName(Configuration configuration) {
|
||||
RenderContext local = create(configuration).renderContext();
|
||||
Schema mappedSchema = Utils.getMappedSchema(configuration, schema);
|
||||
|
||||
if (mappedSchema != null && configuration.dialect() != CUBRID) {
|
||||
local.visit(mappedSchema);
|
||||
local.sql(".");
|
||||
}
|
||||
|
||||
local.literal(name);
|
||||
SequenceImpl.this.toSQL(local);
|
||||
return local.render();
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final void toSQL(RenderContext ctx) {
|
||||
Schema mappedSchema = Utils.getMappedSchema(ctx.configuration(), schema);
|
||||
|
||||
if (mappedSchema != null && ctx.configuration().dialect() != CUBRID) {
|
||||
ctx.visit(mappedSchema);
|
||||
ctx.sql(".");
|
||||
}
|
||||
|
||||
ctx.literal(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void bind(BindContext ctx) {}
|
||||
|
||||
@Override
|
||||
public final Clause[] clauses(Context<?> ctx) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// XXX: Object API
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user