]> source.dussan.org Git - iciql.git/commitdiff
All columns are assumed NULLABLE. IQColumn.allowNull->IQColumn.nullable
authorJames Moger <james.moger@gmail.com>
Tue, 9 Aug 2011 17:56:44 +0000 (13:56 -0400)
committerJames Moger <james.moger@gmail.com>
Tue, 9 Aug 2011 17:56:44 +0000 (13:56 -0400)
docs/01_model_classes.mkd
docs/05_releases.mkd
src/com/iciql/Db.java
src/com/iciql/DbVersion.java
src/com/iciql/Iciql.java
src/com/iciql/TableDefinition.java
src/com/iciql/TableInspector.java
tests/com/iciql/test/ModelsTest.java
tests/com/iciql/test/models/DefaultValuesModel.java

index 274cb92f44506c05ef3079cbb2b12ed5348eb924..bdddd80b943537eb75b10c8f00ed39858ba113ac 100644 (file)
@@ -8,8 +8,9 @@ Alternatively, model classes can be automatically generated by iciql using the m
 ### Configuration Requirements and Limitations\r
 \r
 1. Your model class **must** provide a public default constructor.\r
-2. Only the specified types are supported.  Other types such as arrays and custom types are not supported.\r
-3. Triggers, views, and other advanced database features are not supported.\r
+2. All columns are assumed NULLABLE unless explicitly set *@IQColumn(nullable = false)*. \r
+3. Only the specified types are supported.  Other types such as arrays and custom types are not supported.\r
+4. Triggers, views, and other advanced database features are not supported.\r
 \r
 ### Fully Supported Data Types\r
 The following data types can be used for all iciql expressions.\r
index 8d1295bb12fb8773ae931997ee698b61025671f6..e889f2fa6de9ea0983b05ccdd90b4096144fefbf 100644 (file)
@@ -7,6 +7,8 @@
 **%VERSION%** ([zip](http://code.google.com/p/iciql/downloads/detail?name=%ZIP%)|[jar](http://code.google.com/p/iciql/downloads/detail?name=%JAR%)) &nbsp; *released %BUILDDATE%*\r
 \r
 - api change release (API v4)\r
+- @IQColumn(allowNull=true) -> @IQColumn(nullable=true)\r
+- All columns are assumed NULLABLE unless explicitly set *@IQColumn(nullable = false)*\r
 - allow using objects to assign default values<br/>\r
 %BEGINCODE%\r
 // CREATE TABLE ... myDate DATETIME DEFAULT '2000-02-01 00:00:00'\r
index 621e8257abe07db630a1d6f1743fbeb47b565da5..cae384dc160cf0ee4128890953d183f8c430be1a 100644 (file)
@@ -236,7 +236,7 @@ public class Db {
                                DbVersion v = new DbVersion();\r
                                DbVersion dbVersion =\r
                                // (SCHEMA="" && TABLE="") == DATABASE\r
-                               from(v).where(v.schema).is("").and(v.table).is("").selectFirst();\r
+                               from(v).where(v.schemaName).is("").and(v.tableName).is("").selectFirst();\r
                                if (dbVersion == null) {\r
                                        // database has no version registration, but model specifies\r
                                        // version: insert DbVersion entry and return.\r
@@ -268,14 +268,14 @@ public class Db {
                                // table is using iciql version tracking.\r
                                DbVersion v = new DbVersion();\r
                                String schema = StringUtils.isNullOrEmpty(model.schemaName) ? "" : model.schemaName;\r
-                               DbVersion dbVersion = from(v).where(v.schema).like(schema).and(v.table).like(model.tableName)\r
+                               DbVersion dbVersion = from(v).where(v.schemaName).like(schema).and(v.tableName).like(model.tableName)\r
                                                .selectFirst();\r
                                if (dbVersion == null) {\r
                                        // table has no version registration, but model specifies\r
                                        // version: insert DbVersion entry\r
                                        DbVersion newTable = new DbVersion(model.tableVersion);\r
-                                       newTable.schema = schema;\r
-                                       newTable.table = model.tableName;\r
+                                       newTable.schemaName = schema;\r
+                                       newTable.tableName = model.tableName;\r
                                        insert(newTable);\r
                                } else {\r
                                        // table has a version registration:\r
index 2a8aa442001808d02206e80c2c91a6841e497975..8ccf66f02912194399a67063d4b595d70e5d89c5 100644 (file)
@@ -26,13 +26,13 @@ import com.iciql.Iciql.IQTable;
 @IQTable(name = "_iq_versions", primaryKey = { "schemaName", "tableName"}, memoryTable = true)
 public class DbVersion {
 
-       @IQColumn(name = "schemaName", length = 255, allowNull = false)
-       String schema = "";
+       @IQColumn(length = 255)
+       String schemaName = "";
 
-       @IQColumn(name = "tableName", length = 255, allowNull = false)
-       String table = "";
+       @IQColumn(length = 255)
+       String tableName = "";
 
-       @IQColumn(name = "version")
+       @IQColumn
        Integer version;
 
        public DbVersion() {
@@ -47,8 +47,8 @@ public class DbVersion {
         *            the database version
         */
        public DbVersion(int version) {
-               this.schema = "";
-               this.table = "";
+               this.schemaName = "";
+               this.tableName = "";
                this.version = version;
        }
 
index 2eaf78311d4efb47aabdeaa7158d673ccc8ddc6c..40c412ad6bae3cd97b978a63b16b7c1cd893e69b 100644 (file)
@@ -408,9 +408,9 @@ public interface Iciql {
 \r
                /**\r
                 * If false, iciql will set the column NOT NULL during the CREATE TABLE\r
-                * phase. Default: false.\r
+                * phase. Default: true.\r
                 */\r
-               boolean allowNull() default false;\r
+               boolean nullable() default true;\r
 \r
                /**\r
                 * The default value assigned to the column during the CREATE TABLE\r
index 6e25c91ff892f6e0d5a4839144f6f4fbb12ee873..eb018bcb11638459d71434183b4cea0646502c77 100644 (file)
@@ -75,7 +75,7 @@ public class TableDefinition<T> {
                boolean isPrimaryKey;\r
                boolean isAutoIncrement;\r
                boolean trimString;\r
-               boolean allowNull;\r
+               boolean nullable;\r
                String defaultValue;\r
                EnumType enumType;\r
 \r
@@ -275,7 +275,7 @@ public class TableDefinition<T> {
                        boolean isPrimaryKey = false;\r
                        int maxLength = 0;\r
                        boolean trimString = false;\r
-                       boolean allowNull = true;\r
+                       boolean nullable = true;\r
                        EnumType enumType = null;\r
                        String defaultValue = "";\r
                        // configure Java -> SQL enum mapping\r
@@ -303,7 +303,7 @@ public class TableDefinition<T> {
                                isPrimaryKey = col.primaryKey();\r
                                maxLength = col.length();\r
                                trimString = col.trim();\r
-                               allowNull = col.allowNull();\r
+                               nullable = col.nullable();\r
 \r
                                // try using default object\r
                                try {\r
@@ -340,7 +340,7 @@ public class TableDefinition<T> {
                                fieldDef.isPrimaryKey = isPrimaryKey;\r
                                fieldDef.maxLength = maxLength;\r
                                fieldDef.trimString = trimString;\r
-                               fieldDef.allowNull = allowNull;\r
+                               fieldDef.nullable = nullable;\r
                                fieldDef.defaultValue = defaultValue;\r
                                fieldDef.enumType = enumType;\r
                                fieldDef.dataType = ModelUtils.getDataType(fieldDef, strictTypeMapping);\r
@@ -562,7 +562,7 @@ public class TableDefinition<T> {
                                buff.append(" AUTO_INCREMENT");\r
                        }\r
 \r
-                       if (!field.allowNull) {\r
+                       if (!field.nullable) {\r
                                buff.append(" NOT NULL");\r
                        }\r
 \r
index 6ec848d10f362fde40286bbcc58fbd31b2a5db08..51b2d6932a72001e1af720d636c2740e3e56bb25 100644 (file)
@@ -139,7 +139,7 @@ public class TableInspector {
                                col.type = rs.getString("TYPE_NAME");
                                col.clazz = ModelUtils.getClassForSqlType(col.type, dateTimeClass);
                                col.size = rs.getInt("COLUMN_SIZE");
-                               col.allowNull = rs.getInt("NULLABLE") == DatabaseMetaData.columnNullable;
+                               col.nullable = rs.getInt("NULLABLE") == DatabaseMetaData.columnNullable;
                                col.isAutoIncrement = rs.getBoolean("IS_AUTOINCREMENT");
                                if (primaryKeys.size() == 1) {
                                        if (col.name.equalsIgnoreCase(primaryKeys.get(0))) {
@@ -158,7 +158,7 @@ public class TableInspector {
 
        /**
         * Generates a model (class definition) from this table. The model includes
-        * indexes, primary keys, default values, maxLengths, and allowNull
+        * indexes, primary keys, default values, lengths, and nullables.
         * information.
         * <p>
         * The caller may optionally set a destination package name, whether or not
@@ -369,9 +369,9 @@ public class TableInspector {
                                }
                        }
 
-                       // IQColumn.allowNull
-                       if (!col.allowNull) {
-                               ap.addParameter("allowNull=false");
+                       // IQColumn.nullable
+                       if (!col.nullable) {
+                               ap.addParameter("nullable=false");
                        }
 
                        // IQColumn.defaultValue
@@ -622,7 +622,7 @@ public class TableInspector {
                String name;
                String type;
                int size;
-               boolean allowNull;
+               boolean nullable;
                Class<?> clazz;
                boolean isPrimaryKey;
                boolean isAutoIncrement;
index d5edcfd8ad0c3d1c8ef651afefe941dc717479ff..652bc4f7073b72003011efcbda1a9157d00b7e32 100644 (file)
@@ -115,7 +115,7 @@ public class ModelsTest {
                                true);
                assertEquals(1, models.size());
                // a poor test, but a start
-               assertEquals(1780, models.get(0).length());
+               assertEquals(1456, models.get(0).length());
        }
 
        @Test
index 26692572b838f534f0a772368a658b2eae786af2..ab091867d2a7eefb2e76edfdff4902fa67f5745b 100644 (file)
@@ -50,7 +50,7 @@ public class DefaultValuesModel {
        @IQEnum(EnumType.ORDINAL)\r
        public Tree myOrdinalTree = Tree.PINE;\r
 \r
-       @IQColumn(allowNull = true)\r
+       @IQColumn(nullable = true)\r
        public Tree myNullTree;\r
 \r
        public DefaultValuesModel() {\r