From: James Moger Date: Fri, 12 Aug 2011 18:15:57 +0000 (-0400) Subject: Always enforce strict type mapping. X-Git-Tag: v0.6.4~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=783797ff9ddfafa19481fda5295fcacd3c9b51cd;p=iciql.git Always enforce strict type mapping. --- diff --git a/src/com/iciql/Iciql.java b/src/com/iciql/Iciql.java index 47cf9c1..2917882 100644 --- a/src/com/iciql/Iciql.java +++ b/src/com/iciql/Iciql.java @@ -343,13 +343,6 @@ public interface Iciql { */ boolean create() default true; - /** - * Whether only supported types are mapped. If true, unsupported mapped - * types will throw an IciqlException. If false, unsupported mapped - * types will default to VARCHAR. Default: true. - */ - boolean strictTypeMapping() default true; - /** * If true, only fields that are explicitly annotated as IQColumn are * mapped. Default: true. diff --git a/src/com/iciql/ModelUtils.java b/src/com/iciql/ModelUtils.java index 441bca7..048ce8d 100644 --- a/src/com/iciql/ModelUtils.java +++ b/src/com/iciql/ModelUtils.java @@ -146,11 +146,9 @@ class ModelUtils { * * @param fieldDef * the field to map - * @param strictTypeMapping - * throws a IciqlException if type is unsupported * @return */ - static String getDataType(FieldDefinition fieldDef, boolean strictTypeMapping) { + static String getDataType(FieldDefinition fieldDef) { Class fieldClass = fieldDef.field.getType(); if (fieldClass.isEnum()) { switch (fieldDef.enumType) { @@ -165,9 +163,6 @@ class ModelUtils { if (SUPPORTED_TYPES.containsKey(fieldClass)) { return SUPPORTED_TYPES.get(fieldClass); } - if (!strictTypeMapping) { - return "VARCHAR"; - } throw new IciqlException("Unsupported type " + fieldClass.getName()); } diff --git a/src/com/iciql/TableDefinition.java b/src/com/iciql/TableDefinition.java index 36a28d3..03345d4 100644 --- a/src/com/iciql/TableDefinition.java +++ b/src/com/iciql/TableDefinition.java @@ -261,12 +261,10 @@ public class TableDefinition { void mapFields() { boolean byAnnotationsOnly = false; boolean inheritColumns = false; - boolean strictTypeMapping = false; if (clazz.isAnnotationPresent(IQTable.class)) { IQTable tableAnnotation = clazz.getAnnotation(IQTable.class); byAnnotationsOnly = tableAnnotation.annotationsOnly(); inheritColumns = tableAnnotation.inheritColumns(); - strictTypeMapping = tableAnnotation.strictTypeMapping(); } List classFields = Utils.newArrayList(); @@ -356,7 +354,7 @@ public class TableDefinition { fieldDef.nullable = nullable; fieldDef.defaultValue = defaultValue; fieldDef.enumType = enumType; - fieldDef.dataType = ModelUtils.getDataType(fieldDef, strictTypeMapping); + fieldDef.dataType = ModelUtils.getDataType(fieldDef); fields.add(fieldDef); } } diff --git a/tests/com/iciql/test/models/SupportedTypes.java b/tests/com/iciql/test/models/SupportedTypes.java index 77fdbff..4bd497d 100644 --- a/tests/com/iciql/test/models/SupportedTypes.java +++ b/tests/com/iciql/test/models/SupportedTypes.java @@ -38,7 +38,7 @@ import com.iciql.util.Utils; /** * A data class that contains a column for each data type. */ -@IQTable(strictTypeMapping = true) +@IQTable @IQIndexes({ @IQIndex({ "myLong", "myInteger" }), @IQIndex(type = IndexType.HASH, value = "myString") }) @IQVersion(1) public class SupportedTypes { @@ -185,7 +185,7 @@ public class SupportedTypes { /** * This class demonstrates the table upgrade. */ - @IQTable(name = "SupportedTypes", inheritColumns = true, strictTypeMapping = true) + @IQTable(name = "SupportedTypes", inheritColumns = true) @IQVersion(2) public static class SupportedTypes2 extends SupportedTypes {