[jOOQ/jOOQ#7004] Add support for nextval and currval
This commit is contained in:
parent
8a642ecd80
commit
54aa775f2f
@ -53,6 +53,7 @@ import static org.jooq.SQLDialect.HSQLDB;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
// ...
|
||||
@ -10074,7 +10075,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, POSTGRES })
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES })
|
||||
BigInteger nextval(String sequence) throws DataAccessException;
|
||||
|
||||
/**
|
||||
@ -10083,7 +10084,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, POSTGRES })
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES })
|
||||
BigInteger nextval(Name sequence) throws DataAccessException;
|
||||
|
||||
/**
|
||||
@ -10092,7 +10093,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, POSTGRES })
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES })
|
||||
<T extends Number> T nextval(Sequence<T> sequence) throws DataAccessException;
|
||||
|
||||
/**
|
||||
@ -10101,7 +10102,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
*/
|
||||
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, POSTGRES })
|
||||
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES })
|
||||
BigInteger currval(String sequence) throws DataAccessException;
|
||||
|
||||
/**
|
||||
@ -10110,7 +10111,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
*/
|
||||
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, POSTGRES })
|
||||
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES })
|
||||
BigInteger currval(Name sequence) throws DataAccessException;
|
||||
|
||||
/**
|
||||
@ -10119,7 +10120,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
*/
|
||||
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, POSTGRES })
|
||||
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES })
|
||||
<T extends Number> T currval(Sequence<T> sequence) throws DataAccessException;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@ -47,6 +47,7 @@ import static org.jooq.SQLDialect.H2;
|
||||
import static org.jooq.SQLDialect.HSQLDB;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
@ -82,12 +83,12 @@ public interface Sequence<T extends Number> extends Named {
|
||||
/**
|
||||
* Get the current value of this sequence
|
||||
*/
|
||||
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, POSTGRES })
|
||||
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES })
|
||||
Field<T> currval();
|
||||
|
||||
/**
|
||||
* Increment the sequence and get the next value
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, POSTGRES })
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES })
|
||||
Field<T> nextval();
|
||||
}
|
||||
|
||||
@ -262,6 +262,7 @@ final class Keywords {
|
||||
static final Keyword K_PERCENT = keyword("percent");
|
||||
static final Keyword K_PIVOT = keyword("pivot");
|
||||
static final Keyword K_PRECEDING = keyword("preceding");
|
||||
static final Keyword K_PREVIOUS_VALUE_FOR = keyword("previous value for");
|
||||
static final Keyword K_PRIMARY_KEY = keyword("primary key");
|
||||
static final Keyword K_PRIOR = keyword("prior");
|
||||
static final Keyword K_PROCEDURE = keyword("procedure");
|
||||
|
||||
@ -43,6 +43,7 @@ import static org.jooq.SQLDialect.CUBRID;
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
import static org.jooq.SQLDialect.H2;
|
||||
import static org.jooq.SQLDialect.HSQLDB;
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.select;
|
||||
import static org.jooq.impl.Keywords.F_GEN_ID;
|
||||
@ -50,6 +51,7 @@ import static org.jooq.impl.Keywords.K_CURRENT_VALUE_FOR;
|
||||
import static org.jooq.impl.Keywords.K_CURRVAL;
|
||||
import static org.jooq.impl.Keywords.K_NEXTVAL;
|
||||
import static org.jooq.impl.Keywords.K_NEXT_VALUE_FOR;
|
||||
import static org.jooq.impl.Keywords.K_PREVIOUS_VALUE_FOR;
|
||||
|
||||
import org.jooq.Catalog;
|
||||
import org.jooq.Clause;
|
||||
@ -182,13 +184,16 @@ public class SequenceImpl<T extends Number> extends AbstractNamed implements Seq
|
||||
case DERBY:
|
||||
case FIREBIRD:
|
||||
case H2:
|
||||
case HSQLDB: {
|
||||
case HSQLDB:
|
||||
case MARIADB: {
|
||||
if (method == SequenceMethod.NEXTVAL)
|
||||
ctx.visit(K_NEXT_VALUE_FOR).sql(' ').visit(SequenceImpl.this);
|
||||
else if (family == H2)
|
||||
ctx.visit(SequenceImpl.this).sql('.').visit(method.keyword);
|
||||
else if (family == HSQLDB)
|
||||
ctx.visit(K_CURRENT_VALUE_FOR).sql(' ').visit(SequenceImpl.this);
|
||||
else if (family == MARIADB)
|
||||
ctx.visit(K_PREVIOUS_VALUE_FOR).sql(' ').visit(SequenceImpl.this);
|
||||
else if (family == FIREBIRD)
|
||||
ctx.visit(F_GEN_ID).sql('(').visit(SequenceImpl.this).sql(", 0)");
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user