db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r366016 - in /db/ddlutils/trunk/src/java/org/apache/ddlutils: PlatformInfo.java platform/SqlBuilder.java
Date Wed, 04 Jan 2006 23:09:00 GMT
Author: tomdz
Date: Wed Jan  4 15:08:56 2006
New Revision: 366016

URL: http://svn.apache.org/viewcvs?rev=366016&view=rev
Log:
Added two additional flags to the platform info:

* whether the database returns a synthetic default value for primary key columns (as MySql
does)
* whether default values for LONGVARCHAR/LONGVARBINARY columns are supported

Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformInfo.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformInfo.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformInfo.java?rev=366016&r1=366015&r2=366016&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformInfo.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformInfo.java Wed Jan  4 15:08:56 2006
@@ -38,6 +38,9 @@
     /** Whether the database requires the explicit stating of NULL as the default value.
*/
     private boolean _requiringNullAsDefaultValue = false;
 
+    /** Whether default values can be defined for LONGVARCHAR/LONGVARBINARY columns. */
+    private boolean _supportingDefaultValuesForLongTypes = true;
+
     /** Whether primary key constraints are embedded inside the create table statement. */
     private boolean _primaryKeyEmbedded = true;
     
@@ -112,6 +115,9 @@
         reading a model from a database. */
     private boolean _returningSystemIndices = true;
 
+    /** Whether the database returns a synthetic default value for primary key columns. */

+    private boolean _returningDefaultValueForPrimaryKeys = false;
+    
     /**
      * Creates a new platform info object.
      */
@@ -158,6 +164,26 @@
     }
 
     /**
+     * Determines whether default values can be specified for LONGVARCHAR/LONGVARBINARY columns.
+     *
+     * @return <code>true</code> if default values are allowed
+     */
+    public boolean isSupportingDefaultValuesForLongTypes()
+    {
+        return _supportingDefaultValuesForLongTypes;
+    }
+
+    /**
+     * Specifies whether default values can be specified for LONGVARCHAR/LONGVARBINARY columns.
+     *
+     * @param isSupported <code>true</code> if default values are supported
+     */
+    public void setSupportingDefaultValuesForLongTypes(boolean isSupported)
+    {
+        _supportingDefaultValuesForLongTypes = isSupported;
+    }
+
+    /**
      * Determines whether primary key constraints are embedded in the create 
      * table clause or as seperate alter table statements. The default is
      * embedded pks.
@@ -790,11 +816,35 @@
      * Specifies whether database-generated indices for primary and foreign keys are
      * returned when reading a model from a database.
      *
-     * @param returningSystemIndices <code>true</code> if system indices are
read from a live database
+     * @param returningSystemIndices <code>true</code> if system indices are
read from
+     *                               a live database
      */
     public void setReturningSystemIndices(boolean returningSystemIndices)
     {
         _returningSystemIndices = returningSystemIndices;
+    }
+
+    /**
+     * Determines whether the platform returns synthetic default values (e.g. 0 for numeric
+     * columns etc.) for primary key columns when reading a model from a database.
+     *
+     * @return <code>true</code> if synthetic default values are returned for
pk columns
+     */
+    public boolean isReturningDefaultValueForPrimaryKeys()
+    {
+        return _returningDefaultValueForPrimaryKeys;
+    }
+
+    /**
+     * Specifies whether the platform returns synthetic default values (e.g. 0 for numeric
+     * columns etc.) for primary key columns when reading a model from a database.
+     *
+     * @param returningDefaultValue <code>true</code> if synthetic default values
are returned for
+     *                              pk columns
+     */
+    public void setReturningDefaultValueForPrimaryKeys(boolean returningDefaultValue)
+    {
+        _returningDefaultValueForPrimaryKeys = returningDefaultValue;
     }
 
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java?rev=366016&r1=366015&r2=366016&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java Wed Jan  4 15:08:56
2006
@@ -1116,6 +1116,11 @@
         if ((column.getDefaultValue() != null) ||
             (getPlatformInfo().isIdentitySpecUsesDefaultValue() && column.isAutoIncrement()))
         {
+            if (!getPlatformInfo().isSupportingDefaultValuesForLongTypes() && 
+                ((column.getTypeCode() == Types.LONGVARBINARY) || (column.getTypeCode() ==
Types.LONGVARCHAR)))
+            {
+                throw new DynaSqlException("The platform does not support default values
for LONGVARCHAR or LONGVARBINARY columns");
+            }
             print(" DEFAULT ");
             writeColumnDefaultValue(table, column);
         }



Mime
View raw message