Skip to content

Commit

Permalink
[#1917] Add support for CUBRID 9.0's new features - Added support and
Browse files Browse the repository at this point in the history
documentation for CUBRID's MERGE support
  • Loading branch information
lukaseder committed Nov 2, 2012
1 parent eec8583 commit 4aa381f
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 53 deletions.
16 changes: 7 additions & 9 deletions jOOQ-test/src/org/jooq/test/_/testcases/InsertUpdateTests.java
Expand Up @@ -762,7 +762,6 @@ public void testInsertOnDuplicateKeyIgnore() throws Exception {
public void testMerge() throws Exception {
switch (getDialect()) {
case ASE:
case CUBRID:
case DERBY:
case H2:
case INGRES:
Expand Down Expand Up @@ -878,7 +877,6 @@ public void testMerge() throws Exception {
public void testH2Merge() throws Exception {
switch (getDialect()) {
case ASE:
case CUBRID:
case DERBY:
case INGRES:
case MYSQL:
Expand Down Expand Up @@ -906,8 +904,8 @@ public void testH2Merge() throws Exception {
// H2 MERGE test leading to a single UPDATE
// -------------------------------------------------------------
assertEquals(1,
create().mergeInto(TAuthor(), TAuthor_ID(), TAuthor_FIRST_NAME())
.values(3, "Hermann")
create().mergeInto(TAuthor(), TAuthor_ID(), TAuthor_FIRST_NAME(), TAuthor_LAST_NAME())
.values(3, "Hermann", "Hesse")
.execute());

Result<A> authors2 = create().selectFrom(TAuthor()).orderBy(TAuthor_ID()).fetch();
Expand All @@ -919,9 +917,9 @@ public void testH2Merge() throws Exception {
// H2 MERGE test specifying a custom KEY clause
// -------------------------------------------------------------
assertEquals(1,
create().mergeInto(TAuthor(), TAuthor_FIRST_NAME(), TAuthor_LAST_NAME())
create().mergeInto(TAuthor(), TAuthor_ID(), TAuthor_FIRST_NAME(), TAuthor_LAST_NAME())
.key(TAuthor_LAST_NAME())
.values("Lukas", "Hesse")
.values(3, "Lukas", "Hesse")
.execute());

Result<A> authors3 = create().selectFrom(TAuthor()).orderBy(TAuthor_ID()).fetch();
Expand Down Expand Up @@ -956,14 +954,14 @@ public void testH2Merge() throws Exception {
// H2 MERGE test specifying a subselect
// -------------------------------------------------------------
assertEquals(2,
create().mergeInto(TAuthor(), TAuthor_ID(), TAuthor_FIRST_NAME())
create().mergeInto(TAuthor(), TAuthor_ID(), TAuthor_FIRST_NAME(), TAuthor_LAST_NAME())

// inline() strings here. It seems that DB2 will lack page size
// in the system temporary table space, otherwise

// [#579] TODO: Aliasing shouldn't be necessary
.select(create().select(val(3).as("a"), inline("John").as("b")).unionAll(
create().select(val(4).as("a"), inline("John").as("b"))))
.select(select(val(3).as("a"), inline("John").as("b"), inline("Eder").as("c")).unionAll(
select(val(4).as("a"), inline("John").as("b"), inline("Eder").as("c"))))
.execute());

Result<A> authors5 = create().selectFrom(TAuthor()).orderBy(TAuthor_ID()).fetch();
Expand Down
6 changes: 3 additions & 3 deletions jOOQ/src/main/java/org/jooq/FactoryOperations.java
Expand Up @@ -669,7 +669,7 @@ public interface FactoryOperations extends Configuration {
* statement without field specification. See also
* {@link #mergeInto(Table, Field...)}
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
<R extends Record> MergeUsingStep<R> mergeInto(Table<R> table);

/**
Expand All @@ -692,15 +692,15 @@ public interface FactoryOperations extends Configuration {
* </tr>
* </table>
*/
@Support({ DB2, H2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, H2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
<R extends Record> MergeKeyStep<R> mergeInto(Table<R> table, Field<?>... fields);

/**
* Create a new DSL merge statement (H2-specific syntax)
*
* @see #mergeInto(Table, Field...)
*/
@Support({ DB2, H2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, H2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
<R extends Record> MergeKeyStep<R> mergeInto(Table<R> table, Collection<? extends Field<?>> fields);

/**
Expand Down
5 changes: 3 additions & 2 deletions jOOQ/src/main/java/org/jooq/MergeKeyStep.java
Expand Up @@ -35,6 +35,7 @@
*/
package org.jooq;

import static org.jooq.SQLDialect.CUBRID;
import static org.jooq.SQLDialect.DB2;
import static org.jooq.SQLDialect.H2;
import static org.jooq.SQLDialect.HSQLDB;
Expand Down Expand Up @@ -66,7 +67,7 @@ public interface MergeKeyStep<R extends Record> extends MergeValuesStep<R> {
* Use this optional clause in order to override using the underlying
* <code>PRIMARY KEY</code>.
*/
@Support({ DB2, H2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, H2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeValuesStep<R> key(Field<?>... keys);

/**
Expand All @@ -75,6 +76,6 @@ public interface MergeKeyStep<R extends Record> extends MergeValuesStep<R> {
* Use this optional clause in order to override using the underlying
* <code>PRIMARY KEY</code>.
*/
@Support({ DB2, H2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, H2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeValuesStep<R> key(Collection<? extends Field<?>> keys);
}
7 changes: 4 additions & 3 deletions jOOQ/src/main/java/org/jooq/MergeMatchedSetStep.java
Expand Up @@ -35,6 +35,7 @@
*/
package org.jooq;

import static org.jooq.SQLDialect.CUBRID;
import static org.jooq.SQLDialect.DB2;
import static org.jooq.SQLDialect.HSQLDB;
import static org.jooq.SQLDialect.ORACLE;
Expand Down Expand Up @@ -68,14 +69,14 @@ public interface MergeMatchedSetStep<R extends Record> {
* Set values for <code>UPDATE</code> in the <code>MERGE</code> statement's
* <code>WHEN MATCHED</code> clause
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
<T> MergeMatchedSetMoreStep<R> set(Field<T> field, T value);

/**
* Set values for <code>UPDATE</code> in the <code>MERGE</code> statement's
* <code>WHEN MATCHED</code> clause
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
<T> MergeMatchedSetMoreStep<R> set(Field<T> field, Field<T> value);

/**
Expand All @@ -86,6 +87,6 @@ public interface MergeMatchedSetStep<R extends Record> {
* types. Values can either be of type <code>&lt;T&gt;</code> or
* <code>Field&lt;T&gt;</code>
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeMatchedSetMoreStep<R> set(Map<? extends Field<?>, ?> map);
}
3 changes: 2 additions & 1 deletion jOOQ/src/main/java/org/jooq/MergeMatchedStep.java
Expand Up @@ -35,6 +35,7 @@
*/
package org.jooq;

import static org.jooq.SQLDialect.CUBRID;
import static org.jooq.SQLDialect.DB2;
import static org.jooq.SQLDialect.HSQLDB;
import static org.jooq.SQLDialect.ORACLE;
Expand Down Expand Up @@ -66,6 +67,6 @@ public interface MergeMatchedStep<R extends Record> extends MergeNotMatchedStep<
* Add the <code>WHEN MATCHED THEN UPDATE</code> clause to the
* <code>MERGE</code> statement
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeMatchedSetStep<R> whenMatchedThenUpdate();
}
7 changes: 4 additions & 3 deletions jOOQ/src/main/java/org/jooq/MergeNotMatchedSetStep.java
Expand Up @@ -35,6 +35,7 @@
*/
package org.jooq;

import static org.jooq.SQLDialect.CUBRID;
import static org.jooq.SQLDialect.DB2;
import static org.jooq.SQLDialect.HSQLDB;
import static org.jooq.SQLDialect.ORACLE;
Expand Down Expand Up @@ -68,14 +69,14 @@ public interface MergeNotMatchedSetStep<R extends Record> {
* Set values for <code>INSERT</code> in the <code>MERGE</code> statement's
* <code>WHEN NOT MATCHED</code> clause
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
<T> MergeNotMatchedSetMoreStep<R> set(Field<T> field, T value);

/**
* Set values for <code>INSERT</code> in the <code>MERGE</code> statement's
* <code>WHEN NOT MATCHED</INSERT> clause
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
<T> MergeNotMatchedSetMoreStep<R> set(Field<T> field, Field<T> value);

/**
Expand All @@ -86,6 +87,6 @@ public interface MergeNotMatchedSetStep<R extends Record> {
* types. Values can either be of type <code>&lt;T&gt;</code> or
* <code>Field&lt;T&gt;</code>
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeNotMatchedSetMoreStep<R> set(Map<? extends Field<?>, ?> map);
}
7 changes: 4 additions & 3 deletions jOOQ/src/main/java/org/jooq/MergeNotMatchedStep.java
Expand Up @@ -35,6 +35,7 @@
*/
package org.jooq;

import static org.jooq.SQLDialect.CUBRID;
import static org.jooq.SQLDialect.DB2;
import static org.jooq.SQLDialect.HSQLDB;
import static org.jooq.SQLDialect.ORACLE;
Expand Down Expand Up @@ -73,20 +74,20 @@ public interface MergeNotMatchedStep<R extends Record> extends MergeFinalStep<R>
* access to a MySQL-like API allowing for
* <code>INSERT SET a = x, b = y</code> syntax.
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeNotMatchedSetStep<R> whenNotMatchedThenInsert();

/**
* Add the <code>WHEN NOT MATCHED THEN INSERT</code> clause to the
* <code>MERGE</code> statement
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeNotMatchedValuesStep<R> whenNotMatchedThenInsert(Field<?>... fields);

/**
* Add the <code>WHEN MATCHED THEN UPDATE</code> clause to the
* <code>MERGE</code> statement
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeNotMatchedValuesStep<R> whenNotMatchedThenInsert(Collection<? extends Field<?>> fields);
}
7 changes: 4 additions & 3 deletions jOOQ/src/main/java/org/jooq/MergeNotMatchedValuesStep.java
Expand Up @@ -35,6 +35,7 @@
*/
package org.jooq;

import static org.jooq.SQLDialect.CUBRID;
import static org.jooq.SQLDialect.DB2;
import static org.jooq.SQLDialect.HSQLDB;
import static org.jooq.SQLDialect.ORACLE;
Expand Down Expand Up @@ -68,20 +69,20 @@ public interface MergeNotMatchedValuesStep<R extends Record> {
* Set <code>VALUES</code> for <code>INSERT</code> in the <code>MERGE</code>
* statement's <code>WHEN NOT MATCHED THEN INSERT</code> clause.
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeNotMatchedWhereStep<R> values(Object... values);

/**
* Set <code>VALUES</code> for <code>INSERT</code> in the <code>MERGE</code>
* statement's <code>WHEN NOT MATCHED THEN INSERT</code> clause.
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeNotMatchedWhereStep<R> values(Field<?>... values);

/**
* Set <code>VALUES</code> for <code>INSERT</code> in the <code>MERGE</code>
* statement's <code>WHEN NOT MATCHED THEN INSERT</code> clause.
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeNotMatchedWhereStep<R> values(Collection<?> values);
}
29 changes: 15 additions & 14 deletions jOOQ/src/main/java/org/jooq/MergeOnConditionStep.java
Expand Up @@ -35,6 +35,7 @@
*/
package org.jooq;

import static org.jooq.SQLDialect.CUBRID;
import static org.jooq.SQLDialect.DB2;
import static org.jooq.SQLDialect.HSQLDB;
import static org.jooq.SQLDialect.ORACLE;
Expand Down Expand Up @@ -68,7 +69,7 @@ public interface MergeOnConditionStep<R extends Record> extends MergeMatchedStep
* Combine the currently assembled conditions with another one using the
* {@link Operator#AND} operator and proceed to the next step.
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeOnConditionStep<R> and(Condition condition);

/**
Expand All @@ -82,7 +83,7 @@ public interface MergeOnConditionStep<R extends Record> extends MergeMatchedStep
*
* @see Factory#condition(String)
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeOnConditionStep<R> and(String sql);

/**
Expand All @@ -96,7 +97,7 @@ public interface MergeOnConditionStep<R extends Record> extends MergeMatchedStep
*
* @see Factory#condition(String, Object...)
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeOnConditionStep<R> and(String sql, Object... bindings);

/**
Expand All @@ -110,35 +111,35 @@ public interface MergeOnConditionStep<R extends Record> extends MergeMatchedStep
*
* @see Factory#condition(String, QueryPart...)
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeOnConditionStep<R> and(String sql, QueryPart... parts);

/**
* Combine the currently assembled conditions with a negated other one using
* the {@link Operator#AND} operator and proceed to the next step.
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeOnConditionStep<R> andNot(Condition condition);

/**
* Combine the currently assembled conditions with an EXISTS clause using
* the {@link Operator#AND} operator and proceed to the next step.
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeOnConditionStep<R> andExists(Select<?> select);

/**
* Combine the currently assembled conditions with a NOT EXISTS clause using
* the {@link Operator#AND} operator and proceed to the next step.
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeOnConditionStep<R> andNotExists(Select<?> select);

/**
* Combine the currently assembled conditions with another one using the
* {@link Operator#OR} operator and proceed to the next step.
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeOnConditionStep<R> or(Condition condition);

/**
Expand All @@ -152,7 +153,7 @@ public interface MergeOnConditionStep<R extends Record> extends MergeMatchedStep
*
* @see Factory#condition(String)
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeOnConditionStep<R> or(String sql);

/**
Expand All @@ -166,7 +167,7 @@ public interface MergeOnConditionStep<R extends Record> extends MergeMatchedStep
*
* @see Factory#condition(String, Object...)
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeOnConditionStep<R> or(String sql, Object... bindings);

/**
Expand All @@ -180,27 +181,27 @@ public interface MergeOnConditionStep<R extends Record> extends MergeMatchedStep
*
* @see Factory#condition(String, QueryPart...)
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeOnConditionStep<R> or(String sql, QueryPart... parts);

/**
* Combine the currently assembled conditions with a negated other one using
* the {@link Operator#OR} operator and proceed to the next step.
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeOnConditionStep<R> orNot(Condition condition);

/**
* Combine the currently assembled conditions with an EXISTS clause using
* the {@link Operator#OR} operator and proceed to the next step.
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeOnConditionStep<R> orExists(Select<?> select);

/**
* Combine the currently assembled conditions with a NOT EXISTS clause using
* the {@link Operator#OR} operator and proceed to the next step.
*/
@Support({ DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
MergeOnConditionStep<R> orNotExists(Select<?> select);
}

0 comments on commit 4aa381f

Please sign in to comment.