From 88de2f62da8db03339c5ac2727500aad8b2562de Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Fri, 24 Aug 2012 11:17:54 +0200 Subject: [PATCH] [#430] Add support for the Firebird database - Fixed binding of NULL values to PreparedStatements --- jOOQ/src/main/java/org/jooq/impl/Val.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/impl/Val.java b/jOOQ/src/main/java/org/jooq/impl/Val.java index 0423df9e76..d4f4df355a 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Val.java +++ b/jOOQ/src/main/java/org/jooq/impl/Val.java @@ -59,6 +59,7 @@ import java.util.Arrays; import org.jooq.ArrayRecord; import org.jooq.BindContext; +import org.jooq.Context; import org.jooq.Converter; import org.jooq.DataType; import org.jooq.EnumType; @@ -236,7 +237,7 @@ class Val extends AbstractField implements Param { // [#1727] VARCHAR types should be cast to their actual lengths in some // dialects - else if (getValue() != null && (type == SQLDataType.VARCHAR || type == SQLDataType.CHAR) && asList(FIREBIRD).contains(dialect)) { + else if ((type == SQLDataType.VARCHAR || type == SQLDataType.CHAR) && asList(FIREBIRD).contains(dialect)) { toSQLCast(context, getDataType(context), getValueLength()); } @@ -535,7 +536,7 @@ class Val extends AbstractField implements Param { public final void bind(BindContext context) { // [#1302] Bind value only if it was not explicitly forced to be inlined - if (!isInline()) { + if (!isInline(context)) { context.bindValue(getValue(), getType()); } } @@ -579,7 +580,12 @@ class Val extends AbstractField implements Param { return inline; } + private final boolean isInline(Context context) { + // It looks as though jaybird cannot properly bind NULL! + return isInline() || (context.getDialect() == FIREBIRD && value == null); + } + private final boolean isInline(RenderContext context) { - return isInline() || context.inline(); + return isInline((Context) context) || context.inline(); } }