db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r383134 - in /db/ddlutils/trunk/src: java/org/apache/ddlutils/ java/org/apache/ddlutils/model/ java/org/apache/ddlutils/platform/ java/org/apache/ddlutils/platform/axion/ java/org/apache/ddlutils/task/ test/org/apache/ddlutils/ test/org/apa...
Date Sat, 04 Mar 2006 15:22:08 GMT
Author: tomdz
Date: Sat Mar  4 07:22:07 2006
New Revision: 383134

URL: http://svn.apache.org/viewcvs?rev=383134&view=rev
Log:
Introduced a platform property that defines whether SQL comments shall be generated
Fixed javadoc errors

Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/Platform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformInfo.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/model/ForeignKey.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Reference.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/axion/AxionPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaSqlToFileCommand.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaToDatabaseCommand.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/TestDatabaseWriterBase.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/TestPlatformBase.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySql50Platform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySqlPlatform.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/Platform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/Platform.java?rev=383134&r1=383133&r2=383134&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/Platform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/Platform.java Sat Mar  4 07:22:07 2006
@@ -110,6 +110,8 @@
      */
     public void setPassword(String password);
 
+    // runtime properties
+
     /**
      * Determines whether delimited identifiers are used or normal SQL92 identifiers
      * (which may only contain alphanumerical characters and the underscore, must start
@@ -121,12 +123,28 @@
     public boolean isDelimitedIdentifierModeOn();
 
     /**
-     * Determines whether delimited identifiers are used or normal SQL92 identifiers.
+     * Specifies whether delimited identifiers are used or normal SQL92 identifiers.
      *
      * @param delimitedIdentifierModeOn <code>true</code> if delimited identifiers
shall be used
      */
     public void setDelimitedIdentifierModeOn(boolean delimitedIdentifierModeOn);
 
+    /**
+     * Determines whether SQL comments are generated. 
+     * 
+     * @return <code>true</code> if SQL comments shall be generated
+     */
+    public boolean isSqlCommentsOn();
+
+    /**
+     * Specifies whether SQL comments shall be generated.
+     * 
+     * @param sqlCommentsOn <code>true</code> if SQL comments shall be generated
+     */
+    public void setSqlCommentsOn(boolean sqlCommentsOn);
+
+    // functionality
+    
     /**
      * Returns a (new) JDBC connection from the data source.
      * 

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=383134&r1=383133&r2=383134&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformInfo.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformInfo.java Sat Mar  4 07:22:07 2006
@@ -81,7 +81,7 @@
     // other ddl properties
 
     /** Whether comments are supported. */
-    private boolean _commentsSupported = true;
+    private boolean _sqlCommentsSupported = true;
 
     /** Whether delimited identifiers are supported or not. */
     private boolean _delimitedIdentifiersSupported = true;
@@ -424,23 +424,23 @@
     // other ddl properties
 
     /**
-     * Determines whether the database supports comments.
+     * Determines whether the database supports SQL comments.
      *
      * @return <code>true</code> if comments are supported
      */
-    public boolean isCommentsSupported()
+    public boolean isSqlCommentsSupported()
     {
-        return _commentsSupported;
+        return _sqlCommentsSupported;
     }
 
     /**
-     * Specifies whether comments are supported by the database.
+     * Specifies whether SQL comments are supported by the database.
      * 
      * @param commentsSupported <code>true</code> if comments are supported
      */
-    public void setCommentsSupported(boolean commentsSupported)
+    public void setSqlCommentsSupported(boolean commentsSupported)
     {
-        _commentsSupported = commentsSupported;
+        _sqlCommentsSupported = commentsSupported;
     }
 
     /**

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/model/ForeignKey.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/model/ForeignKey.java?rev=383134&r1=383133&r2=383134&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/model/ForeignKey.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/model/ForeignKey.java Sat Mar  4 07:22:07
2006
@@ -259,6 +259,7 @@
      * Compares this foreign key to the given one while ignoring the case of identifiers.
      * 
      * @param otherFk The other foreign key
+     * @return <code>true</code> if this foreign key is equal (ignoring case)
to the given one
      */
     public boolean equalsIgnoreCase(ForeignKey otherFk)
     {

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Reference.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Reference.java?rev=383134&r1=383133&r2=383134&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Reference.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Reference.java Sat Mar  4 07:22:07
2006
@@ -211,6 +211,7 @@
      * Compares this reference to the given one while ignoring the case of identifiers.
      * 
      * @param otherRef The other reference
+     * @return <code>true</code> if this reference is equal (ignoring case) to
the given one
      */
     public boolean equalsIgnoreCase(Reference otherRef)
     {

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java?rev=383134&r1=383133&r2=383134&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java Sat Mar
 4 07:22:07 2006
@@ -44,6 +44,7 @@
 import org.apache.commons.collections.Predicate;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.ddlutils.DdlUtilsException;
 import org.apache.ddlutils.DynaSqlException;
 import org.apache.ddlutils.Platform;
 import org.apache.ddlutils.PlatformInfo;
@@ -74,6 +75,8 @@
     private SqlBuilder _builder;
     /** The model reader for this platform. */
     private JdbcModelReader _modelReader;
+    /** Whether SQL comments are generated or not. */
+    private boolean _sqlCommentsOn = true;
     /** Whether delimited identifiers are used or not. */
     private boolean _delimitedIdentifierModeOn = false;
 
@@ -128,6 +131,26 @@
     /**
      * {@inheritDoc}
      */
+    public boolean isSqlCommentsOn()
+    {
+        return _sqlCommentsOn;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setSqlCommentsOn(boolean sqlCommentsOn)
+    {
+        if (!getPlatformInfo().isSqlCommentsSupported() && sqlCommentsOn)
+        {
+            throw new DdlUtilsException("Platform " + getName() + " does not support SQL
comments");
+        }
+        _sqlCommentsOn = sqlCommentsOn;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public boolean isDelimitedIdentifierModeOn()
     {
         return _delimitedIdentifierModeOn;
@@ -138,6 +161,10 @@
      */
     public void setDelimitedIdentifierModeOn(boolean delimitedIdentifierModeOn)
     {
+        if (!getPlatformInfo().isDelimitedIdentifiersSupported() && delimitedIdentifierModeOn)
+        {
+            throw new DdlUtilsException("Platform " + getName() + " does not support delimited
identifier");
+        }
         _delimitedIdentifierModeOn = delimitedIdentifierModeOn;
     }
 

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=383134&r1=383133&r2=383134&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 Sat Mar  4 07:22:07
2006
@@ -1897,7 +1897,7 @@
      */
     protected void printComment(String text) throws IOException
     {
-        if (getPlatformInfo().isCommentsSupported())
+        if (getPlatform().isSqlCommentsOn())
         {
             print(getPlatformInfo().getCommentPrefix());
             // Some databases insist on a space after the prefix

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/axion/AxionPlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/axion/AxionPlatform.java?rev=383134&r1=383133&r2=383134&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/axion/AxionPlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/axion/AxionPlatform.java Sat Mar
 4 07:22:07 2006
@@ -44,7 +44,7 @@
         PlatformInfo info = getPlatformInfo();
 
         info.setDelimitedIdentifiersSupported(false);
-        info.setCommentsSupported(false);
+        info.setSqlCommentsSupported(false);
         info.setNullAsDefaultValueRequired(false);
         info.setPrimaryKeyEmbedded(true);
         info.setForeignKeysEmbedded(false);

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaSqlToFileCommand.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaSqlToFileCommand.java?rev=383134&r1=383133&r2=383134&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaSqlToFileCommand.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaSqlToFileCommand.java Sat
Mar  4 07:22:07 2006
@@ -116,6 +116,11 @@
         {
             FileWriter writer = new FileWriter(_outputFile);
 
+            if (platform.getPlatformInfo().isSqlCommentsSupported())
+            {
+                // we're generating SQL comments if possible
+                platform.setSqlCommentsOn(true);
+            }
             platform.getSqlBuilder().setWriter(writer);
             if (isAlterDatabase() && (getDataSource() != null))
             {

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaToDatabaseCommand.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaToDatabaseCommand.java?rev=383134&r1=383133&r2=383134&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaToDatabaseCommand.java
(original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaToDatabaseCommand.java
Sat Mar  4 07:22:07 2006
@@ -90,8 +90,8 @@
         boolean            isCaseSensitive = platform.isDelimitedIdentifierModeOn();
         CreationParameters params          = getFilteredParameters(model, platform.getName(),
isCaseSensitive);
 
-        // we're disabling the comment generation as it is not interesting in this case anyway
-        platform.getPlatformInfo().setCommentsSupported(false);
+        // we're disabling the comment generation because we're writing directly to the database
+        platform.setSqlCommentsOn(false);
         try
         {
             if (isAlterDatabase())

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/TestDatabaseWriterBase.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/TestDatabaseWriterBase.java?rev=383134&r1=383133&r2=383134&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/TestDatabaseWriterBase.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/TestDatabaseWriterBase.java Sat Mar  4
07:22:07 2006
@@ -236,7 +236,7 @@
         {
             _model = model;
 
-            getPlatform().getPlatformInfo().setCommentsSupported(false);
+            getPlatform().setSqlCommentsOn(false);
             getPlatform().createTables(_model, false, false);
         }
         catch (Exception ex)
@@ -256,7 +256,7 @@
         {
             _model = model;
 
-            getPlatform().getPlatformInfo().setCommentsSupported(false);
+            getPlatform().setSqlCommentsOn(false);
             getPlatform().alterTables(_model, true, true, false);
         }
         catch (Exception ex)

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/TestPlatformBase.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/TestPlatformBase.java?rev=383134&r1=383133&r2=383134&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/TestPlatformBase.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/TestPlatformBase.java Sat Mar  4 07:22:07
2006
@@ -226,7 +226,7 @@
         Database testDb = parseDatabaseFromString(schema);
 
         // we're turning the comment creation off to make testing easier
-        getPlatformInfo().setCommentsSupported(false);
+        getPlatform().setSqlCommentsOn(false);
         getPlatform().getSqlBuilder().createTables(testDb);
         return getBuilderOutput();
     }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySql50Platform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySql50Platform.java?rev=383134&r1=383133&r2=383134&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySql50Platform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySql50Platform.java Sat Mar
 4 07:22:07 2006
@@ -89,7 +89,7 @@
         testDb.findTable("constraints").findColumn("COL_AUTO_INCR").setAutoIncrement(false);
         testDb.findTable("constraints").findColumn("COL_PK_AUTO_INCR").setAutoIncrement(false);
 
-        getPlatformInfo().setCommentsSupported(false);
+        getPlatform().setSqlCommentsOn(false);
         getPlatform().getSqlBuilder().createTables(testDb, true);
 
         assertEqualsIgnoringWhitespaces(
@@ -164,7 +164,7 @@
                             "ENGINE",
                             "INNODB");
 
-        getPlatformInfo().setCommentsSupported(false);
+        getPlatform().setSqlCommentsOn(false);
         getPlatform().getSqlBuilder().createTables(testDb, params, true);
 
         assertEqualsIgnoringWhitespaces(

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySqlPlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySqlPlatform.java?rev=383134&r1=383133&r2=383134&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySqlPlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySqlPlatform.java Sat Mar
 4 07:22:07 2006
@@ -100,7 +100,7 @@
         testDb.findTable("constraints").findColumn("COL_AUTO_INCR").setAutoIncrement(false);
         testDb.findTable("constraints").findColumn("COL_PK_AUTO_INCR").setAutoIncrement(false);
 
-        getPlatformInfo().setCommentsSupported(false);
+        getPlatform().setSqlCommentsOn(false);
         getPlatform().getSqlBuilder().createTables(testDb, true);
 
         assertEqualsIgnoringWhitespaces(
@@ -177,7 +177,7 @@
                             "ENGINE",
                             "INNODB");
 
-        getPlatformInfo().setCommentsSupported(false);
+        getPlatform().setSqlCommentsOn(false);
         getPlatform().getSqlBuilder().createTables(testDb, params, true);
 
         assertEqualsIgnoringWhitespaces(



Mime
View raw message