aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--TODO.txt3
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/PropertyMapImpl.java5
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java18
3 files changed, 24 insertions, 2 deletions
diff --git a/TODO.txt b/TODO.txt
index 3c955d5..10c524c 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -27,8 +27,11 @@ Missing pieces:
- numeric data has embedded precision/scale, something else? only last 8
bytes is data? implicit precision of 18 for "pure" numeric? implicit
precision of 15 for double-ish numeric?
+ - ***add unit tests
+ - ***ability to create calculated columns!
- add properties on table/column creation
+ - add unit tests
- calculated fields in queries? (2003+), w/ aliases?
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/PropertyMapImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/PropertyMapImpl.java
index 3c14be2..0667ac8 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/PropertyMapImpl.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/PropertyMapImpl.java
@@ -176,10 +176,11 @@ public class PropertyMapImpl implements PropertyMap
Object value) {
if(type == null) {
- // attempt to figure out the type
- type = DEFAULT_TYPES.get(type);
+ // attempt to get the default type for this property
+ type = DEFAULT_TYPES.get(name);
if(type == null) {
+ // choose the type based on the value
if(value instanceof String) {
type = DataType.TEXT;
} else if(value instanceof Boolean) {
diff --git a/src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java b/src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java
index 182e637..f689328 100644
--- a/src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java
@@ -103,6 +103,24 @@ public class PropertiesTest extends TestCase
colMap.get("buzz")), props);
}
+ public void testInferTypes() throws Exception
+ {
+ PropertyMaps maps = new PropertyMaps(10, null, null);
+ PropertyMap defMap = maps.getDefault();
+
+ assertEquals(DataType.TEXT,
+ defMap.put(PropertyMap.FORMAT_PROP, null).getType());
+ assertEquals(DataType.BOOLEAN,
+ defMap.put(PropertyMap.REQUIRED_PROP, null).getType());
+
+ assertEquals(DataType.TEXT,
+ defMap.put("strprop", "this is a string").getType());
+ assertEquals(DataType.BOOLEAN,
+ defMap.put("boolprop", true).getType());
+ assertEquals(DataType.LONG,
+ defMap.put("intprop", 37).getType());
+ }
+
public void testReadProperties() throws Exception
{
byte[] nameMapBytes = null;