diff --git a/jOOQ-test/.classpath b/jOOQ-test/.classpath
index 7ad0dca22f..1df25163f2 100644
--- a/jOOQ-test/.classpath
+++ b/jOOQ-test/.classpath
@@ -24,6 +24,6 @@
-
+
diff --git a/jOOQ-test/launch/GenerationTool Derby test.launch b/jOOQ-test/launch/GenerationTool Derby test.launch
index 075c64c093..ab0d108417 100644
--- a/jOOQ-test/launch/GenerationTool Derby test.launch
+++ b/jOOQ-test/launch/GenerationTool Derby test.launch
@@ -8,7 +8,7 @@
-
+
diff --git a/jOOQ-test/launch/GenerationTool H2 test.launch b/jOOQ-test/launch/GenerationTool H2 test.launch
index deef07c2ee..3cc7cdde33 100644
--- a/jOOQ-test/launch/GenerationTool H2 test.launch
+++ b/jOOQ-test/launch/GenerationTool H2 test.launch
@@ -8,7 +8,7 @@
-
+
@@ -28,7 +28,7 @@
-
+
diff --git a/jOOQ-test/launch/GenerationTool HSQLDB test.launch b/jOOQ-test/launch/GenerationTool HSQLDB test.launch
index 4e996325aa..da0d199980 100644
--- a/jOOQ-test/launch/GenerationTool HSQLDB test.launch
+++ b/jOOQ-test/launch/GenerationTool HSQLDB test.launch
@@ -8,7 +8,7 @@
-
+
diff --git a/jOOQ-test/launch/GenerationTool MySQL sakila.launch b/jOOQ-test/launch/GenerationTool MySQL sakila.launch
index afc6dc85e0..bd57f885f9 100644
--- a/jOOQ-test/launch/GenerationTool MySQL sakila.launch
+++ b/jOOQ-test/launch/GenerationTool MySQL sakila.launch
@@ -8,7 +8,7 @@
-
+
diff --git a/jOOQ-test/launch/GenerationTool MySQL test.launch b/jOOQ-test/launch/GenerationTool MySQL test.launch
index e3b9023a23..ae68754fed 100644
--- a/jOOQ-test/launch/GenerationTool MySQL test.launch
+++ b/jOOQ-test/launch/GenerationTool MySQL test.launch
@@ -8,7 +8,7 @@
-
+
diff --git a/jOOQ-test/launch/GenerationTool MySQL test2 (schema-rewrite).launch b/jOOQ-test/launch/GenerationTool MySQL test2 (schema-rewrite).launch
index 62890a17ae..52a8f1d9de 100644
--- a/jOOQ-test/launch/GenerationTool MySQL test2 (schema-rewrite).launch
+++ b/jOOQ-test/launch/GenerationTool MySQL test2 (schema-rewrite).launch
@@ -8,7 +8,7 @@
-
+
diff --git a/jOOQ-test/launch/Meta-Generate H2 information_schema.launch b/jOOQ-test/launch/Meta-Generate H2 information_schema.launch
index 83d99ff1f6..5cee50a631 100644
--- a/jOOQ-test/launch/Meta-Generate H2 information_schema.launch
+++ b/jOOQ-test/launch/Meta-Generate H2 information_schema.launch
@@ -26,7 +26,7 @@
-
+
diff --git a/jOOQ-test/launch/Server Client H2.launch b/jOOQ-test/launch/Server Client H2.launch
index 8676411153..f49d35a2a2 100644
--- a/jOOQ-test/launch/Server Client H2.launch
+++ b/jOOQ-test/launch/Server Client H2.launch
@@ -2,7 +2,7 @@
-
+
diff --git a/jOOQ-test/lib/h2-1.3.161.jar b/jOOQ-test/lib/h2-1.3.163.jar
similarity index 53%
rename from jOOQ-test/lib/h2-1.3.161.jar
rename to jOOQ-test/lib/h2-1.3.163.jar
index bf66d474ed..7b1f6dbde0 100644
Binary files a/jOOQ-test/lib/h2-1.3.161.jar and b/jOOQ-test/lib/h2-1.3.163.jar differ
diff --git a/jOOQ-test/src/log4j.xml b/jOOQ-test/src/log4j.xml
index 94aac210fb..31995be684 100644
--- a/jOOQ-test/src/log4j.xml
+++ b/jOOQ-test/src/log4j.xml
@@ -9,7 +9,7 @@
-
+
\ No newline at end of file
diff --git a/jOOQ-test/src/org/jooq/test/jOOQAbstractTest.java b/jOOQ-test/src/org/jooq/test/jOOQAbstractTest.java
index 66c29a9b27..8048ac0e68 100644
--- a/jOOQ-test/src/org/jooq/test/jOOQAbstractTest.java
+++ b/jOOQ-test/src/org/jooq/test/jOOQAbstractTest.java
@@ -6880,7 +6880,6 @@ public abstract class jOOQAbstractTest<
assertEquals("ON STOCK", ((EnumType) value).getLiteral());
}
- @Test
public > void testCustomEnums() throws Exception {
reset = false;
@@ -9048,12 +9047,15 @@ public abstract class jOOQAbstractTest<
assertEquals("asdf", result2.getValue(1, 1));
// [#1028] Named params without any associated type information
- select = create().select(param("p"));
+ // [#1029] TODO Fix this for Postgres!
+ select = create().select(param("p1"), param("p2"));
select.bind(1, "10");
+ select.bind(2, null);
Result> result3 = select.fetch();
assertEquals(1, result3.size());
assertEquals("10", result3.getValue(0, 0));
+ assertEquals(null, result3.getValue(0, 1));
}
@Test
diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractDataType.java b/jOOQ/src/main/java/org/jooq/impl/AbstractDataType.java
index 31d9cbc6a4..8b191f0a1c 100644
--- a/jOOQ/src/main/java/org/jooq/impl/AbstractDataType.java
+++ b/jOOQ/src/main/java/org/jooq/impl/AbstractDataType.java
@@ -311,11 +311,13 @@ public abstract class AbstractDataType implements DataType {
@Override
public final String getCastTypeName(Configuration configuration, int precision, int scale) {
-
- // Remove existing precision / scale information, first
- String result = getCastTypeName(configuration).replaceAll("\\([^\\)]*\\)", "");
+ String result = getCastTypeName(configuration);
if (precision != 0) {
+
+ // Remove existing precision / scale information, first
+ result = result.replaceAll("\\([^\\)]*\\)", "");
+
if (scale != 0) {
result += "(" + precision + ", " + scale + ")";
}
@@ -417,14 +419,7 @@ public abstract class AbstractDataType implements DataType {
}
if (result == null) {
-
- // Object has a default fallback, if it is not registered explicitly
- if (type == Object.class) {
- return new DefaultDataType(dialect, (Class extends T>) Object.class, "", "");
- }
-
- // Default fallback types
- else if (sqlDataTypesByType.get(type) != null) {
+ if (sqlDataTypesByType.get(type) != null) {
return (DataType) sqlDataTypesByType.get(type);
}
diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultBindContext.java b/jOOQ/src/main/java/org/jooq/impl/DefaultBindContext.java
index 06f0a8540f..d889baad0c 100644
--- a/jOOQ/src/main/java/org/jooq/impl/DefaultBindContext.java
+++ b/jOOQ/src/main/java/org/jooq/impl/DefaultBindContext.java
@@ -35,6 +35,10 @@
*/
package org.jooq.impl;
+import static org.jooq.SQLDialect.SQLITE;
+import static org.jooq.SQLDialect.SQLSERVER;
+import static org.jooq.SQLDialect.SYBASE;
+
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Blob;
@@ -120,12 +124,12 @@ class DefaultBindContext extends AbstractBindContext {
// [#725] For SQL Server, unknown types should be set to null
// explicitly, too
- else if (configuration.getDialect() == SQLDialect.SQLSERVER) {
+ else if (configuration.getDialect() == SQLSERVER) {
stmt.setNull(nextIndex(), sqlType);
}
// [#730] For Sybase, unknown types can be set to null using varchar
- else if (configuration.getDialect() == SQLDialect.SYBASE) {
+ else if (configuration.getDialect() == SYBASE) {
stmt.setNull(nextIndex(), Types.VARCHAR);
}
@@ -141,7 +145,7 @@ class DefaultBindContext extends AbstractBindContext {
stmt.setBoolean(nextIndex(), (Boolean) value);
}
else if (type == BigDecimal.class) {
- if (dialect == SQLDialect.SQLITE) {
+ if (dialect == SQLITE) {
stmt.setString(nextIndex(), value.toString());
}
else {
@@ -149,7 +153,7 @@ class DefaultBindContext extends AbstractBindContext {
}
}
else if (type == BigInteger.class) {
- if (dialect == SQLDialect.SQLITE) {
+ if (dialect == SQLITE) {
stmt.setString(nextIndex(), value.toString());
}
else {
diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultDataType.java b/jOOQ/src/main/java/org/jooq/impl/DefaultDataType.java
index 509860d99c..2719b1066b 100644
--- a/jOOQ/src/main/java/org/jooq/impl/DefaultDataType.java
+++ b/jOOQ/src/main/java/org/jooq/impl/DefaultDataType.java
@@ -50,7 +50,7 @@ class DefaultDataType extends AbstractDataType {
*/
private static final long serialVersionUID = -2612295936942892367L;
- protected DefaultDataType(SQLDialect dialect, Class extends T> type, String typeName, String castTypeName) {
+ DefaultDataType(SQLDialect dialect, Class extends T> type, String typeName, String castTypeName) {
super(dialect, null, type, typeName, castTypeName);
}
}
diff --git a/jOOQ/src/main/java/org/jooq/impl/Val.java b/jOOQ/src/main/java/org/jooq/impl/Val.java
index 178e7c8ea4..8c348c7bbb 100644
--- a/jOOQ/src/main/java/org/jooq/impl/Val.java
+++ b/jOOQ/src/main/java/org/jooq/impl/Val.java
@@ -35,6 +35,13 @@
*/
package org.jooq.impl;
+import static java.util.Arrays.asList;
+import static org.jooq.SQLDialect.DB2;
+import static org.jooq.SQLDialect.DERBY;
+import static org.jooq.SQLDialect.HSQLDB;
+import static org.jooq.SQLDialect.INGRES;
+import static org.jooq.SQLDialect.SYBASE;
+
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Collections;
@@ -124,42 +131,49 @@ class Val extends AbstractField implements Param {
* Render the bind variable including a cast, if necessary
*/
private void toSQLCast(RenderContext context) {
- switch (context.getDialect()) {
- // [#822] Some RDBMS need precision / scale information on BigDecimals
- case DB2:
- case DERBY:
- case HSQLDB: {
+ // [#822] Some RDBMS need precision / scale information on BigDecimals
+ if (getType() == BigDecimal.class && asList(DB2, DERBY, HSQLDB).contains(context.getDialect())) {
- // Add precision / scale on BigDecimals
- if (getType() == BigDecimal.class) {
- int scale = ((BigDecimal) getValue()).scale();
- int precision = scale + ((BigDecimal) getValue()).precision();
+ // Add precision / scale on BigDecimals
+ int scale = ((BigDecimal) getValue()).scale();
+ int precision = scale + ((BigDecimal) getValue()).precision();
- context.sql("cast(")
- .sql(getBindVariable(context))
- .sql(" as ")
- .sql(getDataType(context).getCastTypeName(context, precision, scale))
- .sql(")");
- break;
- }
+ toSQLCast(context, getDataType(context), precision, scale);
+ }
- // No break, fall through
- else {
- }
+ // [#1028] Most databases don't know an OTHER type (except H2, HSQLDB).
+ else if (SQLDataType.OTHER == getDataType(context)) {
+
+ // If the bind value is set, it can be used to derive the cast type
+ if (value != null) {
+ toSQLCast(context, FieldTypeHelper.getDataType(context.getDialect(), value.getClass()), 0, 0);
}
- // These dialects don't need precision / scale info on BigDecimals
- case H2:
- case INGRES:
- case SYBASE: {
- context.sql("cast(")
- .sql(getBindVariable(context))
- .sql(" as ")
- .sql(getDataType(context).getCastTypeName(context))
- .sql(")");
+ // [#632] [#722] Current integration tests show that Ingres and
+ // Sybase can do without casting in most cases.
+ else if (asList(INGRES, SYBASE).contains(context.getDialect())) {
+ context.sql(getBindVariable(context));
+ }
+
+ // Derby and DB2 must have a type associated with NULL. Use VARCHAR
+ // as a workaround. That's probably not correct in all cases, though
+ else {
+ toSQLCast(context, FieldTypeHelper.getDataType(context.getDialect(), String.class), 0, 0);
}
}
+
+ else {
+ toSQLCast(context, getDataType(context), 0, 0);
+ }
+ }
+
+ private void toSQLCast(RenderContext context, DataType> type, int precision, int scale) {
+ context.sql("cast(")
+ .sql(getBindVariable(context))
+ .sql(" as ")
+ .sql(type.getCastTypeName(context, precision, scale))
+ .sql(")");
}
/**