]> source.dussan.org Git - iciql.git/commitdiff
IndexValidation was broken for single-indexes or non-standard indexes. v0.6.2
authorJames Moger <james.moger@gmail.com>
Fri, 5 Aug 2011 21:15:45 +0000 (17:15 -0400)
committerJames Moger <james.moger@gmail.com>
Fri, 5 Aug 2011 21:15:45 +0000 (17:15 -0400)
src/com/iciql/Constants.java
src/com/iciql/TableInspector.java
tests/com/iciql/test/ModelsTest.java

index 63bfeff8ee0284a225746403025de8ea925f6e8e..d78f1dbae827ac804e441ce35cff932370af5e51 100644 (file)
@@ -25,7 +25,7 @@ public class Constants {
 \r
        // The build script extracts this exact line so be careful editing it\r
        // and only use A-Z a-z 0-9 .-_ in the string.\r
-       public static final String VERSION = "0.6.1";\r
+       public static final String VERSION = "0.6.2";\r
 \r
        // The build script extracts this exact line so be careful editing it\r
        // and only use A-Z a-z 0-9 .-_ in the string.\r
index 82b732ab5801c9fd1ac67da6f614286cccd8cb98..a4b3b8f6566f5ab3fbb932326f3285d07c7b6472 100644 (file)
@@ -180,7 +180,7 @@ public class TableInspector {
                imports.add(IQTable.class.getCanonicalName());
                imports.add(IQIndexes.class.getCanonicalName());
                imports.add(IQIndex.class.getCanonicalName());
-               imports.add(IQColumn.class.getCanonicalName());         
+               imports.add(IQColumn.class.getCanonicalName());
                imports.add(IndexType.class.getCanonicalName());
 
                // fields
@@ -276,7 +276,8 @@ public class TableInspector {
                AnnotationBuilder ap = new AnnotationBuilder();
                if (indexes.size() == 1) {
                        // single index
-                       ap.append(generateIndexAnnotation(indexes.get(0)));
+                       IndexInspector index = indexes.values().toArray(new IndexInspector[1])[0];
+                       ap.append(generateIndexAnnotation(index));
                        ap.append(eol);
                } else {
                        // multiple indexes
@@ -301,11 +302,11 @@ public class TableInspector {
                        ap.addParameter("name", index.name);
                }
                if (!index.type.equals(IndexType.STANDARD)) {
-                       ap.addParameter("type", IndexType.class.getSimpleName() + "." + index.type.name());
+                       ap.addEnum("type", index.type);
                }
                if (ap.getCount() > 0) {
                        // multiple fields specified
-                       ap.addParameter("values", index.columns);
+                       ap.addParameter("value", index.columns);
                } else {
                        // default value
                        ap.addParameter(null, index.columns);
@@ -685,5 +686,14 @@ public class TableInspector {
                                }
                        }
                }
+
+               void addEnum(String parameter, Enum value) {
+                       appendExceptFirst(", ");
+                       if (!StringUtils.isNullOrEmpty(parameter)) {
+                               append(parameter);
+                               append('=');
+                       }
+                       append(value.getClass().getSimpleName() + "." + value.name());
+               }
        }
 }
\ No newline at end of file
index 90122965b953f06f07d74e353efa03964997b5e7..8fbf219403c6e64e13c147c6961de81eeb4addc5 100644 (file)
@@ -115,7 +115,7 @@ public class ModelsTest {
                                true);
                assertEquals(1, models.size());
                // a poor test, but a start
-               assertEquals(1895, models.get(0).length());
+               assertEquals(1893, models.get(0).length());
        }
 
        @Test