summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/iciql/Query.java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2016-04-04 16:29:28 -0400
committerJames Moger <james.moger@gitblit.com>2016-04-04 16:29:34 -0400
commit13b08bb1e5a955650289c1c2d548883bfeac0de9 (patch)
tree52708d5458f962f845a01a45ef49f78d1421fb83 /src/main/java/com/iciql/Query.java
parentc4c87e4ce044d84d5f2c4e7fa8709e5d699edf8f (diff)
downloadiciql-13b08bb1e5a955650289c1c2d548883bfeac0de9.tar.gz
iciql-13b08bb1e5a955650289c1c2d548883bfeac0de9.zip
Fixes #15: String field not properly trimmed on discrete set
Diffstat (limited to 'src/main/java/com/iciql/Query.java')
-rw-r--r--src/main/java/com/iciql/Query.java15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/main/java/com/iciql/Query.java b/src/main/java/com/iciql/Query.java
index 882fea1..1dbbc4e 100644
--- a/src/main/java/com/iciql/Query.java
+++ b/src/main/java/com/iciql/Query.java
@@ -847,13 +847,24 @@ public class Query<T> {
SelectColumn<T> col = getColumnByReference(alias);
if (col != null && value != null && value.getClass().isEnum()) {
// enum
- EnumType type = col.getFieldDefinition().enumType;
+ TableDefinition.FieldDefinition field = col.getFieldDefinition();
+ EnumType type = field.enumType;
Enum<?> anEnum = (Enum<?>) value;
Object y = Utils.convertEnum(anEnum, type);
stat.addParameter(y);
} else if (col != null) {
// object
- Class<? extends DataTypeAdapter<?>> typeAdapter = col.getFieldDefinition().typeAdapter;
+ TableDefinition.FieldDefinition field = col.getFieldDefinition();
+ Class<? extends DataTypeAdapter<?>> typeAdapter = field.typeAdapter;
+ if (value != null && value instanceof String) {
+ if (field.trim && field.length > 0) {
+ // clip strings (issue-15)
+ String s = (String) value;
+ if (s.length() > field.length) {
+ value = s.substring(0, field.length);
+ }
+ }
+ }
Object parameter = db.getDialect().serialize(value, typeAdapter);
stat.addParameter(parameter);
} else {