diff options
author | James Moger <james.moger@gitblit.com> | 2016-04-04 12:54:42 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2016-04-04 13:33:33 -0400 |
commit | b215ca82bb90f4cd8c0b1e84f91c737da229e6a6 (patch) | |
tree | 924349916cc5c575ba48da6d0543ae7d80b34bf9 /src/main/java/com/iciql/TableDefinition.java | |
parent | 5ede276035ef01d5e3901fe36c45d1bd05efbf8b (diff) | |
download | iciql-b215ca82bb90f4cd8c0b1e84f91c737da229e6a6.tar.gz iciql-b215ca82bb90f4cd8c0b1e84f91c737da229e6a6.zip |
Fix #22: Failure to set fields to null
Diffstat (limited to 'src/main/java/com/iciql/TableDefinition.java')
-rw-r--r-- | src/main/java/com/iciql/TableDefinition.java | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/main/java/com/iciql/TableDefinition.java b/src/main/java/com/iciql/TableDefinition.java index 4fe860d..07f1d48 100644 --- a/src/main/java/com/iciql/TableDefinition.java +++ b/src/main/java/com/iciql/TableDefinition.java @@ -669,9 +669,11 @@ public class TableDefinition<T> { buff.appendExceptFirst(", "); buff.append('?'); Object value = getValue(obj, field); - if (value == null && !field.nullable) { - // try to interpret and instantiate a default value - value = ModelUtils.getDefaultValue(field, db.getDialect().getDateTimeClass()); + if (value == null) { + if (!field.nullable) { + // try to interpret and instantiate a default value + value = ModelUtils.getDefaultValue(field, db.getDialect().getDateTimeClass()); + } } Object parameter = db.getDialect().serialize(value, field.typeAdapter); stat.addParameter(parameter); @@ -737,14 +739,7 @@ public class TableDefinition<T> { // conditionally skip insert of null Object value = getValue(obj, field); if (value == null) { - if (field.nullable) { - // skip null assignment, field is nullable - return true; - } else if (StringUtils.isNullOrEmpty(field.defaultValue)) { - IciqlLogger.warn("no default value, skipping null insert assignment for {0}.{1}", - tableName, field.columnName); - return true; - } + return !StringUtils.isNullOrEmpty(field.defaultValue); } } return false; |