Extracted CHAR casting test to its own test case

This commit is contained in:
Lukas Eder 2012-08-19 13:45:55 +02:00
parent b490fb7df7
commit 6a95dba01e
4 changed files with 17 additions and 11 deletions

View File

@ -54,6 +54,7 @@ import static org.jooq.impl.Factory.cast;
import static org.jooq.impl.Factory.castNull;
import static org.jooq.impl.Factory.dateAdd;
import static org.jooq.impl.Factory.dateDiff;
import static org.jooq.impl.Factory.field;
import static org.jooq.impl.Factory.inline;
import static org.jooq.impl.Factory.timestampAdd;
import static org.jooq.impl.Factory.timestampDiff;
@ -122,6 +123,17 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T658,
super(delegate);
}
@Test
public void testCharCasts() throws Exception {
// [#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"))
.fetchOne(0, String.class));
}
@Test
public void testBlobAndClob() throws Exception {
jOOQAbstractTest.reset = false;

View File

@ -137,7 +137,6 @@ import org.jooq.SelectQuery;
import org.jooq.Table;
import org.jooq.TableRecord;
import org.jooq.UpdatableRecord;
import org.jooq.impl.SQLDataType;
import org.jooq.test.BaseTest;
import org.jooq.test.jOOQAbstractTest;
@ -403,13 +402,6 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T658,
@Test
public void testFunctionsOnStrings() throws Exception {
// [#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"))
.fetchOne(0, String.class));
// Trimming
assertEquals("abc", create().select(trim("abc")).fetchOne(0));
assertEquals("abc", create().select(trim("abc ")).fetchOne(0));

View File

@ -886,6 +886,11 @@ public abstract class jOOQAbstractTest<
new DataTypeTests(this).testCastingToJavaClass();
}
@Test
public void testCharCasts() throws Exception {
new DataTypeTests(this).testCharCasts();
}
@Test
public void testNestedCasting() throws Exception {
new DataTypeTests(this).testNestedCasting();

View File

@ -713,14 +713,11 @@ public class jOOQFirebirdTest extends jOOQAbstractTest<
FirebirdDataType.INT,
FirebirdDataType.INTEGER,
FirebirdDataType.NUMERIC,
FirebirdDataType.OBJECT,
FirebirdDataType.OTHER,
FirebirdDataType.SMALLINT,
FirebirdDataType.TIME,
FirebirdDataType.TIMESTAMP,
FirebirdDataType.TINYINT,
FirebirdDataType.VARCHAR,
FirebirdDataType.VARCHARIGNORECASE,
};
}
}