[#1257] Add CUBRID support - Fixed some issues
This commit is contained in:
parent
dcfd44c414
commit
7c003bbbf7
@ -43,9 +43,21 @@ import static org.jooq.impl.Factory.count;
|
||||
import static org.jooq.impl.Factory.field;
|
||||
import static org.jooq.impl.Factory.literal;
|
||||
import static org.jooq.impl.Factory.max;
|
||||
import static org.jooq.impl.Factory.one;
|
||||
import static org.jooq.impl.Factory.substring;
|
||||
import static org.jooq.impl.Factory.sum;
|
||||
import static org.jooq.impl.Factory.table;
|
||||
import static org.jooq.impl.Factory.trueCondition;
|
||||
import static org.jooq.impl.Factory.val;
|
||||
import static org.jooq.util.oracle.OracleFactory.connectByIsCycle;
|
||||
import static org.jooq.util.oracle.OracleFactory.connectByIsLeaf;
|
||||
import static org.jooq.util.oracle.OracleFactory.level;
|
||||
import static org.jooq.util.oracle.OracleFactory.prior;
|
||||
import static org.jooq.util.oracle.OracleFactory.rownum;
|
||||
import static org.jooq.util.oracle.OracleFactory.sysConnectByPath;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Record;
|
||||
@ -214,7 +226,7 @@ extends BaseTest<A, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T658, T725
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRelationalDivision() {
|
||||
public void testRelationalDivision() throws Exception {
|
||||
|
||||
// Books and bookstores. There's only one book that is contained in
|
||||
// every bookstore:
|
||||
@ -248,4 +260,120 @@ extends BaseTest<A, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T658, T725
|
||||
assertEquals(asList((Object) 1, "abc"), asList(result.get(0).intoArray()));
|
||||
assertEquals(asList((Object) 3, "abc"), asList(result.get(1).intoArray()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnectBySimple() throws Exception {
|
||||
switch (getDialect()) {
|
||||
case ASE:
|
||||
case DB2:
|
||||
case DERBY:
|
||||
case H2:
|
||||
case HSQLDB:
|
||||
case INGRES:
|
||||
case MYSQL:
|
||||
case POSTGRES:
|
||||
case SQLITE:
|
||||
case SQLSERVER:
|
||||
case SYBASE:
|
||||
log.info("SKIPPING", "Connect by tests");
|
||||
return;
|
||||
}
|
||||
|
||||
assertEquals(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9),
|
||||
create().select(rownum())
|
||||
.connectBy(level().lessThan(10))
|
||||
.fetch(rownum()));
|
||||
assertEquals(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9),
|
||||
create().select(rownum())
|
||||
.connectByNoCycle(level().lessThan(10))
|
||||
.fetch(rownum()));
|
||||
|
||||
assertEquals(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9),
|
||||
create().select(rownum())
|
||||
.connectBy(level().lessThan(10))
|
||||
.and("1 = ?", 1)
|
||||
.startWith("? = ?", 1, 1)
|
||||
.fetch(rownum()));
|
||||
assertEquals(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9),
|
||||
create().select(rownum())
|
||||
.connectByNoCycle(level().lessThan(10))
|
||||
.and("1 = ?", 1)
|
||||
.startWith("? = ?", 1, 1)
|
||||
.fetch(rownum()));
|
||||
|
||||
Result<Record> result =
|
||||
create().select(rownum(), connectByIsCycle(), connectByIsLeaf())
|
||||
.connectByNoCycle(level().lessThan(4))
|
||||
.fetch();
|
||||
|
||||
assertEquals(Integer.valueOf(1), result.getValue(0, rownum()));
|
||||
assertEquals(Integer.valueOf(2), result.getValue(1, rownum()));
|
||||
assertEquals(Integer.valueOf(3), result.getValue(2, rownum()));
|
||||
|
||||
assertEquals(Boolean.FALSE, result.getValue(0, connectByIsLeaf()));
|
||||
assertEquals(Boolean.FALSE, result.getValue(1, connectByIsLeaf()));
|
||||
assertEquals(Boolean.TRUE, result.getValue(2, connectByIsLeaf()));
|
||||
|
||||
assertEquals(Boolean.FALSE, result.getValue(0, connectByIsCycle()));
|
||||
assertEquals(Boolean.FALSE, result.getValue(1, connectByIsCycle()));
|
||||
assertEquals(Boolean.FALSE, result.getValue(2, connectByIsCycle()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnectByDirectory() throws Exception {
|
||||
switch (getDialect()) {
|
||||
case ASE:
|
||||
case DB2:
|
||||
case DERBY:
|
||||
case H2:
|
||||
case HSQLDB:
|
||||
case INGRES:
|
||||
case MYSQL:
|
||||
case POSTGRES:
|
||||
case SQLITE:
|
||||
case SQLSERVER:
|
||||
case SYBASE:
|
||||
log.info("SKIPPING", "Connect by tests");
|
||||
return;
|
||||
}
|
||||
|
||||
List<?> paths =
|
||||
create().select(substring(sysConnectByPath(TDirectory_NAME(), "/"), 2))
|
||||
.from(TDirectory())
|
||||
.where(trueCondition())
|
||||
.and(trueCondition())
|
||||
.connectBy(prior(TDirectory_ID()).equal(TDirectory_PARENT_ID()))
|
||||
.startWith(TDirectory_PARENT_ID().isNull())
|
||||
.orderBy(one())
|
||||
.fetch(0);
|
||||
|
||||
assertEquals(26, paths.size());
|
||||
assertEquals(Arrays.asList(
|
||||
"C:",
|
||||
"C:/eclipse",
|
||||
"C:/eclipse/configuration",
|
||||
"C:/eclipse/dropins",
|
||||
"C:/eclipse/eclipse.exe",
|
||||
"C:/eclipse/eclipse.ini",
|
||||
"C:/eclipse/features",
|
||||
"C:/eclipse/plugins",
|
||||
"C:/eclipse/p2",
|
||||
"C:/eclipse/readme",
|
||||
"C:/eclipse/readme/readme_eclipse.html",
|
||||
"C:/eclipse/src",
|
||||
"C:/Program Files",
|
||||
"C:/Program Files/Internet Explorer",
|
||||
"C:/Program Files/Internet Explorer/de-DE",
|
||||
"C:/Program Files/Internet Explorer/ielowutil.exe",
|
||||
"C:/Program Files/Internet Explorer/iexplore.exe",
|
||||
"C:/Program Files/Java",
|
||||
"C:/Program Files/Java/jre6",
|
||||
"C:/Program Files/Java/jre6/bin",
|
||||
"C:/Program Files/Java/jre6/bin/java.exe",
|
||||
"C:/Program Files/Java/jre6/bin/javaw.exe",
|
||||
"C:/Program Files/Java/jre6/bin/javaws.exe",
|
||||
"C:/Program Files/Java/jre6/lib",
|
||||
"C:/Program Files/Java/jre6/lib/javaws.jar",
|
||||
"C:/Program Files/Java/jre6/lib/rt.jar"), paths);
|
||||
}
|
||||
}
|
||||
|
||||
@ -392,7 +392,8 @@ extends BaseTest<A, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T658, T725
|
||||
@Test
|
||||
public void testFunctionsOnStrings() throws Exception {
|
||||
|
||||
// [#1241] TODO Casting. This doesn't work in Derby
|
||||
// [#1241] Casting to CHAR. Some dialects don't like that. They should
|
||||
// be casting to VARCHAR instead
|
||||
assertEquals("abc",
|
||||
create().select(field("cast('abc' as char(3))", SQLDataType.CHAR))
|
||||
.where(field("cast('abc' as char(3))", SQLDataType.CHAR).equal("abc"))
|
||||
|
||||
@ -167,10 +167,12 @@ extends BaseTest<A, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T658, T725
|
||||
|
||||
// INSERT MULTIPLE .. RETURNING
|
||||
// ----------------------------
|
||||
// TODO [#1260] This probably works for CUBRID
|
||||
// TODO [#832] Make this work for Sybase also
|
||||
// TODO [#1004] Make this work for SQL Server also
|
||||
// TODO ... and then, think about Ingres, H2 and Derby as well
|
||||
if (getDialect() == SYBASE ||
|
||||
if (getDialect() == CUBRID ||
|
||||
getDialect() == SYBASE ||
|
||||
getDialect() == SQLSERVER ||
|
||||
getDialect() == INGRES ||
|
||||
getDialect() == H2 ||
|
||||
@ -521,6 +523,9 @@ extends BaseTest<A, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T658, T725
|
||||
|
||||
switch (getDialect()) {
|
||||
case ASE:
|
||||
// TODO [#1260] This should work eventually, when CUBRID fixes this
|
||||
// JDBC bug
|
||||
case CUBRID:
|
||||
case DERBY:
|
||||
case H2:
|
||||
case INGRES:
|
||||
|
||||
@ -40,6 +40,9 @@ import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.jooq.SQLDialect.CUBRID;
|
||||
import static org.jooq.SQLDialect.DB2;
|
||||
import static org.jooq.SQLDialect.INGRES;
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
import static org.jooq.impl.Factory.count;
|
||||
import static org.jooq.impl.Factory.falseCondition;
|
||||
@ -139,7 +142,7 @@ extends BaseTest<A, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T658, T725
|
||||
|
||||
// This query causes a failure in Ingres. Potentially a bug. See E_OP039F_BOOLFACT on
|
||||
// http://docs.ingres.com/ingres/9.2/ingres-92-message-guide/1283-errors-from-opf#E_OP039F_BOOLFACT
|
||||
if (getDialect() != SQLDialect.DB2 && getDialect() != SQLDialect.INGRES) {
|
||||
if (!asList(CUBRID, DB2, INGRES).contains(getDialect())) {
|
||||
|
||||
// Advanced JOIN usages with single JOIN condition
|
||||
Result<Record> result = create().select()
|
||||
@ -420,7 +423,8 @@ extends BaseTest<A, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T658, T725
|
||||
public void testInverseAndNestedJoin() throws Exception {
|
||||
|
||||
// [#1086] TODO: Fix this for SQLite
|
||||
if (getDialect() == SQLITE) {
|
||||
// In CUBRID, it is not suupported
|
||||
if (getDialect() == SQLITE || getDialect() == CUBRID) {
|
||||
log.info("SKIPPING", "Nested JOINs");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1427,6 +1427,16 @@ public abstract class jOOQAbstractTest<
|
||||
new ExoticTests(this).testRelationalDivision();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnectBySimple() throws Exception {
|
||||
new ExoticTests(this).testConnectBySimple();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnectByDirectory() throws Exception {
|
||||
new ExoticTests(this).testConnectByDirectory();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecuteListenerOnResultQuery() throws Exception {
|
||||
new ExecuteListenerTests(this).testExecuteListenerOnResultQuery();
|
||||
|
||||
@ -42,8 +42,6 @@ import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNull;
|
||||
import static org.jooq.impl.Factory.currentUser;
|
||||
import static org.jooq.impl.Factory.falseCondition;
|
||||
import static org.jooq.impl.Factory.one;
|
||||
import static org.jooq.impl.Factory.substring;
|
||||
import static org.jooq.impl.Factory.table;
|
||||
import static org.jooq.impl.Factory.trueCondition;
|
||||
import static org.jooq.impl.Factory.val;
|
||||
@ -77,20 +75,12 @@ import static org.jooq.test.oracle.generatedclasses.test.udt.UAuthorType.countBo
|
||||
import static org.jooq.test.oracle.generatedclasses.test.udt.UAuthorType.load;
|
||||
import static org.jooq.test.oracle2.generatedclasses.Tables.DATE_AS_TIMESTAMP_T_976;
|
||||
import static org.jooq.test.oracle2.generatedclasses.udt.DateAsTimestampT_976ObjectType.DATE_AS_TIMESTAMP_T_976_OBJECT_TYPE;
|
||||
import static org.jooq.util.oracle.OracleFactory.connectByIsCycle;
|
||||
import static org.jooq.util.oracle.OracleFactory.connectByIsLeaf;
|
||||
import static org.jooq.util.oracle.OracleFactory.level;
|
||||
import static org.jooq.util.oracle.OracleFactory.prior;
|
||||
import static org.jooq.util.oracle.OracleFactory.rownum;
|
||||
import static org.jooq.util.oracle.OracleFactory.sysConnectByPath;
|
||||
import static org.jooq.util.oracle.OracleFactory.sysContext;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.sql.Date;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.jooq.ArrayRecord;
|
||||
import org.jooq.DataType;
|
||||
@ -832,90 +822,6 @@ public class jOOQOracleTest extends jOOQAbstractTest<
|
||||
assertEquals(1, create().selectDistinct(val(1)).hint("/*+ALL_ROWS*/").fetchOne(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOracleConnectBySimple() throws Exception {
|
||||
assertEquals(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9),
|
||||
ora().select(rownum())
|
||||
.connectBy(level().lessThan(10))
|
||||
.fetch(rownum()));
|
||||
assertEquals(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9),
|
||||
ora().select(rownum())
|
||||
.connectByNoCycle(level().lessThan(10))
|
||||
.fetch(rownum()));
|
||||
|
||||
assertEquals(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9),
|
||||
ora().select(rownum())
|
||||
.connectBy(level().lessThan(10))
|
||||
.and("1 = ?", 1)
|
||||
.startWith("? = ?", 1, 1)
|
||||
.fetch(rownum()));
|
||||
assertEquals(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9),
|
||||
ora().select(rownum())
|
||||
.connectByNoCycle(level().lessThan(10))
|
||||
.and("1 = ?", 1)
|
||||
.startWith("? = ?", 1, 1)
|
||||
.fetch(rownum()));
|
||||
|
||||
Result<Record> result =
|
||||
ora().select(rownum(), connectByIsCycle(), connectByIsLeaf())
|
||||
.connectByNoCycle(level().lessThan(4))
|
||||
.fetch();
|
||||
|
||||
assertEquals(Integer.valueOf(1), result.getValue(0, rownum()));
|
||||
assertEquals(Integer.valueOf(2), result.getValue(1, rownum()));
|
||||
assertEquals(Integer.valueOf(3), result.getValue(2, rownum()));
|
||||
|
||||
assertEquals(Boolean.FALSE, result.getValue(0, connectByIsLeaf()));
|
||||
assertEquals(Boolean.FALSE, result.getValue(1, connectByIsLeaf()));
|
||||
assertEquals(Boolean.TRUE, result.getValue(2, connectByIsLeaf()));
|
||||
|
||||
assertEquals(Boolean.FALSE, result.getValue(0, connectByIsCycle()));
|
||||
assertEquals(Boolean.FALSE, result.getValue(1, connectByIsCycle()));
|
||||
assertEquals(Boolean.FALSE, result.getValue(2, connectByIsCycle()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOracleConnectByDirectory() throws Exception {
|
||||
List<?> paths =
|
||||
ora().select(substring(sysConnectByPath(TDirectory_NAME(), "/"), 2))
|
||||
.from(TDirectory())
|
||||
.where(trueCondition())
|
||||
.and(trueCondition())
|
||||
.connectBy(prior(TDirectory_ID()).equal(TDirectory_PARENT_ID()))
|
||||
.startWith(TDirectory_PARENT_ID().isNull())
|
||||
.orderBy(one())
|
||||
.fetch(0);
|
||||
|
||||
assertEquals(26, paths.size());
|
||||
assertEquals(Arrays.asList(
|
||||
"C:",
|
||||
"C:/eclipse",
|
||||
"C:/eclipse/configuration",
|
||||
"C:/eclipse/dropins",
|
||||
"C:/eclipse/eclipse.exe",
|
||||
"C:/eclipse/eclipse.ini",
|
||||
"C:/eclipse/features",
|
||||
"C:/eclipse/plugins",
|
||||
"C:/eclipse/p2",
|
||||
"C:/eclipse/readme",
|
||||
"C:/eclipse/readme/readme_eclipse.html",
|
||||
"C:/eclipse/src",
|
||||
"C:/Program Files",
|
||||
"C:/Program Files/Internet Explorer",
|
||||
"C:/Program Files/Internet Explorer/de-DE",
|
||||
"C:/Program Files/Internet Explorer/ielowutil.exe",
|
||||
"C:/Program Files/Internet Explorer/iexplore.exe",
|
||||
"C:/Program Files/Java",
|
||||
"C:/Program Files/Java/jre6",
|
||||
"C:/Program Files/Java/jre6/bin",
|
||||
"C:/Program Files/Java/jre6/bin/java.exe",
|
||||
"C:/Program Files/Java/jre6/bin/javaw.exe",
|
||||
"C:/Program Files/Java/jre6/bin/javaws.exe",
|
||||
"C:/Program Files/Java/jre6/lib",
|
||||
"C:/Program Files/Java/jre6/lib/javaws.jar",
|
||||
"C:/Program Files/Java/jre6/lib/rt.jar"), paths);
|
||||
}
|
||||
|
||||
// @Test [#1119] TODO reactivate this test
|
||||
public void testOraclePipelinedFunctions() throws Exception {
|
||||
// TODO [#1113] [#1119] Standalone calls to pipelined functions should
|
||||
|
||||
@ -182,6 +182,7 @@ public interface Table<R extends Record> extends Type<R>, AliasProvider<Table<R>
|
||||
* <p>
|
||||
* This has been observed to work with all dialects
|
||||
*/
|
||||
@Support
|
||||
DivideByOnStep divideBy(Table<?> divisor);
|
||||
|
||||
/**
|
||||
|
||||
@ -336,14 +336,15 @@ class InsertQueryImpl<R extends Record> extends AbstractStoreQuery<R> implements
|
||||
// SQLite will select last_insert_rowid() after the INSER
|
||||
case SQLITE:
|
||||
// Sybase will select @@identity after the INSERT
|
||||
case CUBRID:
|
||||
case SYBASE:
|
||||
super.prepare(ctx);
|
||||
return;
|
||||
|
||||
// Some dialects can only return AUTO_INCREMENT values
|
||||
// Other values have to be fetched in a second step
|
||||
// [#1260] TODO CUBRID supports this, but there's a JDBC bug
|
||||
case ASE:
|
||||
case CUBRID:
|
||||
case DERBY:
|
||||
case H2:
|
||||
case INGRES:
|
||||
@ -397,6 +398,7 @@ class InsertQueryImpl<R extends Record> extends AbstractStoreQuery<R> implements
|
||||
// TODO [#832] Fix this. This might be a driver issue. JDBC
|
||||
// Generated keys don't work with jconn3, but they seem to work
|
||||
// with jTDS (which is used for Sybase ASE integration)
|
||||
case CUBRID:
|
||||
case SYBASE: {
|
||||
listener.executeStart(ctx);
|
||||
result = ctx.statement().executeUpdate();
|
||||
@ -408,8 +410,8 @@ class InsertQueryImpl<R extends Record> extends AbstractStoreQuery<R> implements
|
||||
|
||||
// Some dialects can only retrieve "identity" (AUTO_INCREMENT) values
|
||||
// Additional values have to be fetched explicitly
|
||||
// [#1260] TODO CUBRID supports this, but there's a JDBC bug
|
||||
case ASE:
|
||||
case CUBRID:
|
||||
case DERBY:
|
||||
case H2:
|
||||
case INGRES:
|
||||
|
||||
@ -153,6 +153,10 @@ class Val<T> extends AbstractField<T> implements Param<T>, BindingProvider {
|
||||
// [#722] TODO This is probably not entirely right.
|
||||
case INGRES:
|
||||
|
||||
// [#1261] There are only a few corner-cases, where this is
|
||||
// really needed. Check back on related CUBRID bugs
|
||||
case CUBRID:
|
||||
|
||||
// [#1029] Postgres and [#632] Sybase need explicit casting
|
||||
// in very rare cases.
|
||||
case POSTGRES:
|
||||
@ -183,7 +187,7 @@ class Val<T> extends AbstractField<T> implements Param<T>, BindingProvider {
|
||||
SQLDataType<T> type = getDataType(context).getSQLDataType();
|
||||
|
||||
// [#822] Some RDBMS need precision / scale information on BigDecimals
|
||||
if (getValue() != null && getType() == BigDecimal.class && asList(DB2, DERBY, HSQLDB).contains(context.getDialect())) {
|
||||
if (getValue() != null && getType() == BigDecimal.class && asList(CUBRID, DB2, DERBY, HSQLDB).contains(context.getDialect())) {
|
||||
|
||||
// Add precision / scale on BigDecimals
|
||||
int scale = ((BigDecimal) getValue()).scale();
|
||||
|
||||
@ -79,8 +79,8 @@ public class CUBRIDDataType<T> extends AbstractDataType<T> {
|
||||
public static final CUBRIDDataType<String> VARCHAR = new CUBRIDDataType<String>(SQLDataType.VARCHAR, "varchar");
|
||||
public static final CUBRIDDataType<String> CHARVARYING = new CUBRIDDataType<String>(SQLDataType.VARCHAR, "char varying");
|
||||
public static final CUBRIDDataType<String> CHARACTERVARYING = new CUBRIDDataType<String>(SQLDataType.VARCHAR, "character varying");
|
||||
public static final CUBRIDDataType<String> CHAR = new CUBRIDDataType<String>(SQLDataType.CHAR, "char");
|
||||
public static final CUBRIDDataType<String> CHARACTER = new CUBRIDDataType<String>(SQLDataType.CHAR, "character");
|
||||
public static final CUBRIDDataType<String> CHAR = new CUBRIDDataType<String>(SQLDataType.CHAR, "char", "varchar");
|
||||
public static final CUBRIDDataType<String> CHARACTER = new CUBRIDDataType<String>(SQLDataType.CHAR, "character", "varchar");
|
||||
public static final CUBRIDDataType<String> STRING = new CUBRIDDataType<String>(SQLDataType.VARCHAR, "string");
|
||||
public static final CUBRIDDataType<String> NCHAR = new CUBRIDDataType<String>(SQLDataType.NCHAR, "nchar");
|
||||
public static final CUBRIDDataType<String> NCHARVARYING = new CUBRIDDataType<String>(SQLDataType.NVARCHAR, "nchar varying");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user