[#2492] MS Access fixes

This commit is contained in:
Lukas Eder 2014-02-10 18:04:14 +01:00
parent 79da3b8b04
commit e8f5e484dc
14 changed files with 111 additions and 44 deletions

View File

@ -725,7 +725,7 @@ xxxxxx xxxxx xxxxxxxxxx xxxxxxx xxxxxxxxxxxxxxxxx
xxxxxxxxx
xxxxxxxxx xxxxxxx xxxxxxxxxxxxxxxxxxxx x
xxxxxx xxxxx
xxxxxx xxxxxx
x
xxxxxxxxx

View File

@ -471,6 +471,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
public void testConnectByDirectory() throws Exception {
switch (dialect().family()) {
/* [pro] xx
xxxx xxxxxxx
xxxx xxxx
xxxx xxxx
xxxx xxxxxxx

View File

@ -47,6 +47,7 @@ import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
// ...
import static org.jooq.SQLDialect.H2;
// ...
import static org.jooq.SQLDialect.POSTGRES;
@ -1619,21 +1620,29 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
ResultSet rs = create().resultQuery("select * from t_author order by id").fetchResultSet();
assertTrue(rs.next());
assertEquals(1, rs.getInt(1));
assertEquals(1, rs.getInt(1));
assertFalse(rs.wasNull());
assertEquals(1, rs.getInt(TAuthor_ID().getName()));
assertEquals((short) 1, rs.getShort(TAuthor_ID().getName()));
assertEquals(1L, rs.getLong(TAuthor_ID().getName()));
assertEquals(AUTHOR_FIRST_NAMES.get(0), rs.getString(2));
assertEquals(AUTHOR_FIRST_NAMES.get(0), rs.getString(TAuthor_FIRST_NAME().getName()));
assertEquals(AUTHOR_LAST_NAMES.get(0), rs.getString(3));
assertEquals(AUTHOR_LAST_NAMES.get(0), rs.getString(TAuthor_LAST_NAME().getName()));
// Some JDBC drivers don't cache ResultSet. The same value cannot be fetched twice, then.
if (!asList().contains(dialect().family())) {
assertEquals(1, rs.getInt(1));
assertEquals(1, rs.getInt(TAuthor_ID().getName()));
assertEquals((short) 1, rs.getShort(TAuthor_ID().getName()));
assertEquals(1L, rs.getLong(TAuthor_ID().getName()));
assertEquals(AUTHOR_FIRST_NAMES.get(0), rs.getString(TAuthor_FIRST_NAME().getName()));
assertEquals(AUTHOR_LAST_NAMES.get(0), rs.getString(TAuthor_LAST_NAME().getName()));
}
assertTrue(rs.next());
assertEquals(2, rs.getInt(1));
assertEquals(2, rs.getInt(1));
assertFalse(rs.wasNull());
assertEquals(2, rs.getInt(TAuthor_ID().getName()));
// Some JDBC drivers don't cache ResultSet. The same value cannot be fetched twice, then.
if (!asList().contains(dialect().family())) {
assertEquals(2, rs.getInt(1));
assertEquals(2, rs.getInt(TAuthor_ID().getName()));
}
assertFalse(rs.next());
rs.close();

View File

@ -752,6 +752,24 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
Field<Float> f6a = sqlite || ingres ? inline(1.11f) : trunc(1.111f, 2);
Field<Float> f7a = sqlite || ingres ? inline(10.0f) : trunc(11.111f, -1);
Record r1 =
create().select(f1a)
.select(f2a, f3a)
.select(f4a)
.select(f5a, f6a, f7a)
.fetchOne();
assertNotNull(r1);
assertEquals("1.0", r1.getValue(f1a, String.class));
assertEquals("1.11", r1.getValue(f2a, String.class));
assertEquals("1.0", r1.getValue(f3a, String.class));
assertEquals("2.0", r1.getValue(f4a, String.class));
assertEquals("1.0", r1.getValue(f5a, String.class));
assertEquals("1.11", r1.getValue(f6a, String.class));
assertEquals("10.0", r1.getValue(f7a, String.class));
Field<Double> f1b = round(-1.111);
Field<Double> f2b = round(-1.111, 2);
Field<Double> f3b = floor(-1.111);
@ -760,6 +778,20 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
Field<Double> f6b = sqlite || ingres ? inline(1.11) : trunc(1.111, 2);
Field<Double> f7b = sqlite || ingres ? inline(10.0) : trunc(11.111, -1);
Record r2 =
create().select(f1b, f2b, f3b, f4b, f6b, f6b, f7b)
.fetchOne();
assertEquals("-1.0", r2.getValue(f1b, String.class));
assertEquals("-1.11", r2.getValue(f2b, String.class));
assertEquals("-2.0", r2.getValue(f3b, String.class));
assertEquals("-1.0", r2.getValue(f4b, String.class));
assertEquals("1.0", r2.getValue(f5b, String.class));
assertEquals("1.11", r2.getValue(f6b, String.class));
assertEquals("10.0", r2.getValue(f7b, String.class));
Field<Float> f1c = round(2.0f);
Field<Float> f2c = round(2.0f, 2);
Field<Float> f3c = floor(2.0f);
@ -778,36 +810,13 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
Field<Double> f3f = floor(0.0);
Field<Double> f4f = ceil(0.0);
// Some arbitrary checks on having multiple select clauses
Record record =
create().select(f1a)
.select(f2a, f3a)
.select(f4a)
.select(f5a, f6a, f7a)
.select(f1b, f2b, f3b, f4b, f6b, f6b, f7b)
.select(f1c, f2c, f3c, f4c)
create().select(f1c, f2c, f3c, f4c)
.select(f1d, f2d, f3d, f4d)
.select(f1e, f2e, f3e, f4e)
.select(f1f, f2f, f3f, f4f)
.fetchOne();
assertNotNull(record);
assertEquals("1.0", record.getValue(f1a, String.class));
assertEquals("1.11", record.getValue(f2a, String.class));
assertEquals("1.0", record.getValue(f3a, String.class));
assertEquals("2.0", record.getValue(f4a, String.class));
assertEquals("1.0", record.getValue(f5a, String.class));
assertEquals("1.11", record.getValue(f6a, String.class));
assertEquals("10.0", record.getValue(f7a, String.class));
assertEquals("-1.0", record.getValue(f1b, String.class));
assertEquals("-1.11", record.getValue(f2b, String.class));
assertEquals("-2.0", record.getValue(f3b, String.class));
assertEquals("-1.0", record.getValue(f4b, String.class));
assertEquals("1.0", record.getValue(f5b, String.class));
assertEquals("1.11", record.getValue(f6b, String.class));
assertEquals("10.0", record.getValue(f7b, String.class));
assertEquals("2.0", record.getValue(f1c, String.class));
assertEquals("2.0", record.getValue(f2c, String.class));
assertEquals("2.0", record.getValue(f3c, String.class));

View File

@ -45,6 +45,7 @@ import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
// ...
// ...
import static org.jooq.SQLDialect.CUBRID;
// ...
import static org.jooq.SQLDialect.DERBY;
@ -230,6 +231,13 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
@Test
public void testInsertDefaultValues() throws Exception {
/* [pro] xx
xx xxxxxxxxxxxxxxxxxxx xx xxxxxxx x
xxxxxxxxxxxxxxxxxxxx xxxxxxxx xxxxxx xxxxxxx
xxxxxxx
x
xx [/pro] */
jOOQAbstractTest.reset = false;
assertEquals(1,

View File

@ -88,6 +88,11 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
@SuppressWarnings("unchecked")
@Test
public void testFetchParentAndChildren() throws Exception {
if (!supportsReferences()) {
log.info("SKIPPING", "Fetch parent and children tests");
return;
}
Result<A> authors = create().selectFrom(TAuthor()).orderBy(TAuthor_ID()).fetch();
Result<B> books = create().selectFrom(TBook()).orderBy(TBook_ID()).fetch();

View File

@ -229,11 +229,14 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
@Test
public void testManyVarcharBindValues() throws Exception {
int n = 300;
/* [pro] xx
xx xxxxxxx xx xxxxxxxx xxxxx xxxxx xx xxx xxxxxxxx
xx [/pro] */
int n = 255;
String s = "1234567890";
// [#1726] Check if large amounts of VARCHAR bind values can be handled
// [#1726] Check if "large" amounts of VARCHAR bind values can be handled
Record record = create().select(Collections.nCopies(n, val(s))).fetchOne();
assertEquals(n, record.size());
assertEquals(Collections.nCopies(n, s), asList(record.intoArray()));

View File

@ -171,8 +171,8 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
.and(row(1).between(0).and(2))
.and(row(1).betweenSymmetric(row(2), row(0)))
.and(row(1).betweenSymmetric(2).and(0))
.and(row(1).notBetween(row(2), row(0)))
.and(row(1).notBetween(2).and(0))
.and(row(1).notBetween(row(2), row(4)))
.and(row(1).notBetween(2).and(4))
.and(row(1).notBetweenSymmetric(row(3), row(5)))
.and(row(1).notBetweenSymmetric(3).and(5))
.fetchOne(0, Integer.class));

View File

@ -113,6 +113,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
public void testTruncateCascade() throws Exception {
switch (dialect().family()) {
/* [pro] xx
xxxx xxxxxxx
xxxx xxxx
xxxx xxxx
xxxx xxxxxxx

View File

@ -40,6 +40,22 @@
*/
package org.jooq;
// ...
import static org.jooq.SQLDialect.CUBRID;
// ...
import static org.jooq.SQLDialect.DERBY;
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.SQLDialect.MYSQL;
// ...
import static org.jooq.SQLDialect.POSTGRES;
import static org.jooq.SQLDialect.SQLITE;
// ...
// ...
import java.util.Collection;
import java.util.Map;
@ -125,7 +141,7 @@ public interface InsertSetStep<R extends Record> {
/**
* Add an empty record with default values.
*/
@Support
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
InsertReturningStep<R> defaultValues();
/**

View File

@ -40,7 +40,7 @@
*/
package org.jooq.impl;
import static org.jooq.impl.DSL.function;
import static org.jooq.impl.DSL.field;
import org.jooq.Configuration;
import org.jooq.Field;
@ -67,6 +67,11 @@ class Ceil<T extends Number> extends AbstractFunction<T> {
final Field<T> getFunction0(Configuration configuration) {
switch (configuration.dialect().family()) {
/* [pro] xx
xxxx xxxxxxx
xxxxxx xxxxxxxxxxxxxxxxxxx x xxxx x xxxxxxxxx x xxxxx xxxxxxxxxxxxxx xxxxxxxxxx
xx [/pro] */
// evaluate "ceil" if unavailable
case SQLITE:
return DSL.round(argument.add(0.499999999999999));
@ -76,10 +81,10 @@ class Ceil<T extends Number> extends AbstractFunction<T> {
xxxx xxxxxxxxxx
xx [/pro] */
case H2:
return function("ceiling", getDataType(), argument);
return field("{ceiling}({0})", getDataType(), argument);
default:
return function("ceil", getDataType(), argument);
return field("{ceil}({0})", getDataType(), argument);
}
}
}

View File

@ -40,7 +40,7 @@
*/
package org.jooq.impl;
import static org.jooq.impl.DSL.function;
import static org.jooq.impl.DSL.field;
import org.jooq.Configuration;
import org.jooq.Field;
@ -67,12 +67,15 @@ class Floor<T extends Number> extends AbstractFunction<T> {
final Field<T> getFunction0(Configuration configuration) {
switch (configuration.dialect()) {
// evaluate "floor" if unavailable
/* [pro] xx
xxxx xxxxxxx
xx [/pro] */
case SQLITE:
return DSL.round(argument.sub(0.499999999999999));
default:
return function("floor", getDataType(), argument);
return field("{floor}({0})", getDataType(), argument);
}
}
}

View File

@ -40,6 +40,7 @@
*/
package org.jooq.impl;
import static org.jooq.impl.DSL.field;
import static org.jooq.impl.DSL.function;
import static org.jooq.impl.DSL.one;
import static org.jooq.impl.DSL.zero;
@ -69,6 +70,11 @@ class Sign extends AbstractFunction<Integer> {
@Override
final Field<Integer> getFunction0(Configuration configuration) {
switch (configuration.dialect()) {
/* [pro] xx
xxxx xxxxxxx
xxxxxx xxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxx xxxxxxxxxx
xx [/pro] */
case SQLITE:
return DSL.decode()
.when(((Field<Integer>) argument).greaterThan(zero()), one())

View File

@ -91,6 +91,7 @@ class Trunc<T> extends AbstractFunction<T> {
private final Field<T> getNumericFunction(Configuration configuration) {
switch (configuration.dialect().family()) {
/* [pro] xx
xxxx xxxxxxx
xxxx xxxx
xx [/pro] */
case DERBY: {