From 98819d6577c7190028660c4b3a5e3c13492297c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Prante?= Date: Mon, 21 Aug 2023 09:25:05 +0200 Subject: [PATCH] add null as allowed value in SQL statement --- gradle.properties | 2 +- .../src/main/java/org/xbib/jdbc/query/DatabaseImpl.java | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 875d071..61a6736 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group = org.xbib name = database -version = 1.4.1 +version = 1.4.2 org.gradle.warning.mode = ALL diff --git a/jdbc-query/src/main/java/org/xbib/jdbc/query/DatabaseImpl.java b/jdbc-query/src/main/java/org/xbib/jdbc/query/DatabaseImpl.java index 9520131..17207b6 100644 --- a/jdbc-query/src/main/java/org/xbib/jdbc/query/DatabaseImpl.java +++ b/jdbc-query/src/main/java/org/xbib/jdbc/query/DatabaseImpl.java @@ -485,8 +485,10 @@ public class DatabaseImpl implements Database { sql.argLocalDate(k, (LocalDate) v); } else if (v instanceof LocalDateTime) { sql.argLocalDateTime(k, (LocalDateTime) v); + } else if (v == null) { + sql.argNull(k); } else { - throw new DatabaseException("unknown type for param: " + (v != null ? v.getClass() : "null")); + throw new DatabaseException("unknown type for param: " + v.getClass()); } }); } @@ -508,8 +510,10 @@ public class DatabaseImpl implements Database { sql.argLocalDate(k, (LocalDate) v); } else if (v instanceof LocalDateTime) { sql.argLocalDateTime(k, (LocalDateTime) v); + } else if (v == null) { + sql.argNull(k); } else { - throw new DatabaseException("unknown type for param: " + (v != null ? v.getClass() : "null")); + throw new DatabaseException("unknown type for param: " + v.getClass()); } }); }