aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2018-02-07 21:50:11 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2018-02-07 21:50:11 +0000
commit71d884e1ad50d415ad781a217f64ee57c31b8081 (patch)
treea5814c5d9811debca6481dce2ce66c7ecf918557 /src
parenta307c8f58f02d68629a53c52dbefd50f8e4f97db (diff)
downloadjackcess-71d884e1ad50d415ad781a217f64ee57c31b8081.tar.gz
jackcess-71d884e1ad50d415ad781a217f64ee57c31b8081.zip
update ddl flag for default properties even if type is explicitly provided. fixes #146
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@1138 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src')
-rw-r--r--src/changes/changes.xml3
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/PropertyMapImpl.java66
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);
}
}