]> source.dussan.org Git - iciql.git/commitdiff
Always enforce strict type mapping.
authorJames Moger <james.moger@gmail.com>
Fri, 12 Aug 2011 18:15:57 +0000 (14:15 -0400)
committerJames Moger <james.moger@gmail.com>
Fri, 12 Aug 2011 18:15:57 +0000 (14:15 -0400)
src/com/iciql/Iciql.java
src/com/iciql/ModelUtils.java
src/com/iciql/TableDefinition.java
tests/com/iciql/test/models/SupportedTypes.java

index 47cf9c1f8069b3c4d982d18153fe197707665333..2917882baf4056afc1a0d57136dad1da0394dd8b 100644 (file)
@@ -343,13 +343,6 @@ public interface Iciql {
                 */\r
                boolean create() default true;\r
 \r
-               /**\r
-                * Whether only supported types are mapped. If true, unsupported mapped\r
-                * types will throw an IciqlException. If false, unsupported mapped\r
-                * types will default to VARCHAR. Default: true.\r
-                */\r
-               boolean strictTypeMapping() default true;\r
-\r
                /**\r
                 * If true, only fields that are explicitly annotated as IQColumn are\r
                 * mapped. Default: true.\r
index 441bca7ad60805e01677ba4281b318d43bcdc2b3..048ce8d936deba32aba6322f34b6e1e092da99ae 100644 (file)
@@ -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());
        }
 
index 36a28d3d50d22587a4d872b7ab2404b354be127a..03345d4ce9c61990292c657834cc41266ec6559e 100644 (file)
@@ -261,12 +261,10 @@ public class TableDefinition<T> {
        void mapFields() {\r
                boolean byAnnotationsOnly = false;\r
                boolean inheritColumns = false;\r
-               boolean strictTypeMapping = false;\r
                if (clazz.isAnnotationPresent(IQTable.class)) {\r
                        IQTable tableAnnotation = clazz.getAnnotation(IQTable.class);\r
                        byAnnotationsOnly = tableAnnotation.annotationsOnly();\r
                        inheritColumns = tableAnnotation.inheritColumns();\r
-                       strictTypeMapping = tableAnnotation.strictTypeMapping();\r
                }\r
 \r
                List<Field> classFields = Utils.newArrayList();\r
@@ -356,7 +354,7 @@ public class TableDefinition<T> {
                                fieldDef.nullable = nullable;\r
                                fieldDef.defaultValue = defaultValue;\r
                                fieldDef.enumType = enumType;\r
-                               fieldDef.dataType = ModelUtils.getDataType(fieldDef, strictTypeMapping);\r
+                               fieldDef.dataType = ModelUtils.getDataType(fieldDef);\r
                                fields.add(fieldDef);\r
                        }\r
                }\r
index 77fdbff07655bd0cd4023b7bea57c6eda23237ae..4bd497d8290f445f1889008bc6d393852fd08584 100644 (file)
@@ -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 {