diff options
-rw-r--r-- | src/changes/changes.xml | 3 | ||||
-rw-r--r-- | src/main/java/com/healthmarketscience/jackcess/impl/PropertyMapImpl.java | 66 |
2 files changed, 35 insertions, 34 deletions
diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 6ea08e6..6b9e945 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -9,6 +9,9 @@ Expose the "ddl" attribute on properties. Set the attribute appropriately for known builtin properties. </action> + <action dev="jahlborn" type="fix" system="SourceForge2" issue="146"> + Set ddl flag even if property type is explicitly provided. + </action> </release> <release version="2.1.10" date="2018-01-18"> <action dev="jahlborn" type="update" system="SourceForge2Features" diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/PropertyMapImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/PropertyMapImpl.java index 61c19a0..137426c 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/PropertyMapImpl.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/PropertyMapImpl.java @@ -176,41 +176,39 @@ public class PropertyMapImpl implements PropertyMap public static Property createProperty(String name, DataType type, Object value, boolean isDdl) { - if(type == null) { - - // attempt to get the default type for this property - PropDef pd = DEFAULT_TYPES.get(name); - - if(pd != null) { - type = pd._type; - isDdl |= pd._isDdl; + // see if this is a builtin property that we already understand + PropDef pd = DEFAULT_TYPES.get(name); + + if(pd != null) { + // update according to the default info + type = ((type == null) ? pd._type : type); + isDdl |= pd._isDdl; + } else if(type == null) { + // choose the type based on the value + if(value instanceof String) { + type = DataType.TEXT; + } else if(value instanceof Boolean) { + type = DataType.BOOLEAN; + } else if(value instanceof Byte) { + type = DataType.BYTE; + } else if(value instanceof Short) { + type = DataType.INT; + } else if(value instanceof Integer) { + type = DataType.LONG; + } else if(value instanceof Float) { + type = DataType.FLOAT; + } else if(value instanceof Double) { + type = DataType.DOUBLE; + } else if(value instanceof Date) { + type = DataType.SHORT_DATE_TIME; + } else if(value instanceof byte[]) { + type = DataType.OLE; + } else if(value instanceof Long) { + type = DataType.BIG_INT; } else { - // choose the type based on the value - if(value instanceof String) { - type = DataType.TEXT; - } else if(value instanceof Boolean) { - type = DataType.BOOLEAN; - } else if(value instanceof Byte) { - type = DataType.BYTE; - } else if(value instanceof Short) { - type = DataType.INT; - } else if(value instanceof Integer) { - type = DataType.LONG; - } else if(value instanceof Float) { - type = DataType.FLOAT; - } else if(value instanceof Double) { - type = DataType.DOUBLE; - } else if(value instanceof Date) { - type = DataType.SHORT_DATE_TIME; - } else if(value instanceof byte[]) { - type = DataType.OLE; - } else if(value instanceof Long) { - type = DataType.BIG_INT; - } else { - throw new IllegalArgumentException( - "Could not determine type for property " + name + - " with value " + value); - } + throw new IllegalArgumentException( + "Could not determine type for property " + name + + " with value " + value); } } |