cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From johnth...@apache.org
Subject svn commit: r1511516 - in /cayenne/sandbox/cayenne-migrations/src/main/java/org/apache/cayenne/migration: MigrationGenerator.java MigrationTable.java
Date Wed, 07 Aug 2013 22:05:32 GMT
Author: johnthuss
Date: Wed Aug  7 22:05:32 2013
New Revision: 1511516

URL: http://svn.apache.org/r1511516
Log:
Allow specifying a length for Timestamp, Time, Blob, and Clob columns since some DBs support
it

Modified:
    cayenne/sandbox/cayenne-migrations/src/main/java/org/apache/cayenne/migration/MigrationGenerator.java
    cayenne/sandbox/cayenne-migrations/src/main/java/org/apache/cayenne/migration/MigrationTable.java

Modified: cayenne/sandbox/cayenne-migrations/src/main/java/org/apache/cayenne/migration/MigrationGenerator.java
URL: http://svn.apache.org/viewvc/cayenne/sandbox/cayenne-migrations/src/main/java/org/apache/cayenne/migration/MigrationGenerator.java?rev=1511516&r1=1511515&r2=1511516&view=diff
==============================================================================
--- cayenne/sandbox/cayenne-migrations/src/main/java/org/apache/cayenne/migration/MigrationGenerator.java
(original)
+++ cayenne/sandbox/cayenne-migrations/src/main/java/org/apache/cayenne/migration/MigrationGenerator.java
Wed Aug  7 22:05:32 2013
@@ -24,6 +24,7 @@ import java.io.Writer;
 import java.sql.Types;
 
 import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.dba.TypesMapping;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
@@ -235,8 +236,11 @@ public class MigrationGenerator {
 	}
 	
 	protected boolean hasLength(int type) {
-		return type == Types.BINARY || type == Types.CHAR || 
-			   type == Types.VARBINARY || type == Types.VARCHAR;
+		return TypesMapping.supportsLength(type) 
+		        || type == Types.BLOB // for Derby
+		        || type == Types.CLOB // for Derby
+		        || type == Types.TIMESTAMP // for MySQL
+		        || type == Types.TIME; // for MySQL
 	}
 	
 }

Modified: cayenne/sandbox/cayenne-migrations/src/main/java/org/apache/cayenne/migration/MigrationTable.java
URL: http://svn.apache.org/viewvc/cayenne/sandbox/cayenne-migrations/src/main/java/org/apache/cayenne/migration/MigrationTable.java?rev=1511516&r1=1511515&r2=1511516&view=diff
==============================================================================
--- cayenne/sandbox/cayenne-migrations/src/main/java/org/apache/cayenne/migration/MigrationTable.java
(original)
+++ cayenne/sandbox/cayenne-migrations/src/main/java/org/apache/cayenne/migration/MigrationTable.java
Wed Aug  7 22:05:32 2013
@@ -125,10 +125,16 @@ public abstract class MigrationTable {
 	}
 	
 	public MigrationColumnNew addBlobColumn(String columnName) {
-		return addBlobColumn(columnName, false, null);
+		return addBlobColumn(columnName, 0, false, null);
+	}
+	public MigrationColumnNew addBlobColumn(String columnName, int maxLength) {
+	    return addBlobColumn(columnName, maxLength, false, null);
 	}
 	public MigrationColumnNew addBlobColumn(String columnName, boolean isMandatory, Object defaultValue)
{
-		return addColumn(columnName, Types.BLOB, isMandatory, defaultValue);
+	    return addBlobColumn(columnName, 0, isMandatory, defaultValue);
+	}
+	public MigrationColumnNew addBlobColumn(String columnName, int maxLength, boolean isMandatory,
Object defaultValue) {
+		return addColumn(columnName, Types.BLOB, maxLength, isMandatory, defaultValue);
 	}
 	
 	public MigrationColumnNew addCharColumn(String columnName, int maxLength) {
@@ -148,8 +154,14 @@ public abstract class MigrationTable {
 	public MigrationColumnNew addClobColumn(String columnName) {
 		return addClobColumn(columnName, false, null);
 	}
+	public MigrationColumnNew addClobColumn(String columnName, int maxLength) {
+	    return addClobColumn(columnName, maxLength, false, null);
+	}
 	public MigrationColumnNew addClobColumn(String columnName, boolean isMandatory, Object defaultValue)
{
-		return addColumn(columnName, Types.CLOB, isMandatory, defaultValue);
+	    return addClobColumn(columnName, 0, false, null);
+	}
+	public MigrationColumnNew addClobColumn(String columnName, int maxLength, boolean isMandatory,
Object defaultValue) {
+		return addColumn(columnName, Types.CLOB, maxLength, isMandatory, defaultValue);
 	}
 	
 	public MigrationColumnNew addDateColumn(String columnName) {
@@ -223,17 +235,29 @@ public abstract class MigrationTable {
 	}
 	
 	public MigrationColumnNew addTimeColumn(String columnName) {
-		return addTimeColumn(columnName, false, null);
+		return addTimeColumn(columnName, 0, false, null);
 	}
-	public MigrationColumnNew addTimeColumn(String columnName, boolean isMandatory, Object defaultValue)
{
-		return addColumn(columnName, Types.TIME, isMandatory, defaultValue);
+    public MigrationColumnNew addTimeColumn(String columnName, boolean isMandatory, Object
defaultValue) {
+        return addTimeColumn(columnName, 0, isMandatory, defaultValue);
+    }
+    public MigrationColumnNew addTimeColumn(String columnName, int maxLength) {
+        return addTimeColumn(columnName, maxLength, false, null);
+    }
+	public MigrationColumnNew addTimeColumn(String columnName, int maxLength, boolean isMandatory,
Object defaultValue) {
+		return addColumn(columnName, Types.TIME, maxLength, isMandatory, defaultValue);
 	}
 	
 	public MigrationColumnNew addTimestampColumn(String columnName) {
-		return addTimestampColumn(columnName, false, null);
+		return addTimestampColumn(columnName, 0, false, null);
 	}
-	public MigrationColumnNew addTimestampColumn(String columnName, boolean isMandatory, Object
defaultValue) {
-		return addColumn(columnName, Types.TIMESTAMP, isMandatory, defaultValue);
+    public MigrationColumnNew addTimestampColumn(String columnName, boolean isMandatory,
Object defaultValue) {
+        return addTimestampColumn(columnName, 0, isMandatory, defaultValue);
+    }
+    public MigrationColumnNew addTimestampColumn(String columnName, int maxLength) {
+        return addTimestampColumn(columnName, maxLength, false, null);
+    }
+	public MigrationColumnNew addTimestampColumn(String columnName, int maxLength, boolean isMandatory,
Object defaultValue) {
+		return addColumn(columnName, Types.TIMESTAMP, maxLength, isMandatory, defaultValue);
 	}
 	
 	public MigrationColumnNew addTinyIntColumn(String columnName) {



Mime
View raw message