summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/iciql/Query.java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2016-04-04 12:54:42 -0400
committerJames Moger <james.moger@gitblit.com>2016-04-04 13:33:33 -0400
commitb215ca82bb90f4cd8c0b1e84f91c737da229e6a6 (patch)
tree924349916cc5c575ba48da6d0543ae7d80b34bf9 /src/main/java/com/iciql/Query.java
parent5ede276035ef01d5e3901fe36c45d1bd05efbf8b (diff)
downloadiciql-b215ca82bb90f4cd8c0b1e84f91c737da229e6a6.tar.gz
iciql-b215ca82bb90f4cd8c0b1e84f91c737da229e6a6.zip
Fix #22: Failure to set fields to null
Diffstat (limited to 'src/main/java/com/iciql/Query.java')
-rw-r--r--src/main/java/com/iciql/Query.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main/java/com/iciql/Query.java b/src/main/java/com/iciql/Query.java
index 694f42e..882fea1 100644
--- a/src/main/java/com/iciql/Query.java
+++ b/src/main/java/com/iciql/Query.java
@@ -274,6 +274,10 @@ public class Query<T> {
return stat.executeUpdate();
}
+ public <A> Query<T> setNull(A field) {
+ return set(field).to(null);
+ }
+
public <A> UpdateColumnSet<T, A> set(A field) {
from.getAliasDefinition().checkMultipleEnums(field);
return new UpdateColumnSet<T, A>(this, field);
@@ -776,7 +780,7 @@ public class Query<T> {
token.appendSQL(stat, this);
return;
}
- if (alias != null && value.getClass().isEnum()) {
+ if (alias != null && value != null && value.getClass().isEnum()) {
// special case:
// value is first enum constant which is also the alias object.
// the first enum constant is used as the alias because we can not
@@ -841,7 +845,7 @@ public class Query<T> {
private void addParameter(SQLStatement stat, Object alias, Object value) {
SelectColumn<T> col = getColumnByReference(alias);
- if (col != null && value.getClass().isEnum()) {
+ if (col != null && value != null && value.getClass().isEnum()) {
// enum
EnumType type = col.getFieldDefinition().enumType;
Enum<?> anEnum = (Enum<?>) value;