db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r366028 - in /db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql: MySqlModelReader.java MySqlPlatform.java
Date Wed, 04 Jan 2006 23:33:21 GMT
Author: tomdz
Date: Wed Jan  4 15:33:17 2006
New Revision: 366028

URL: http://svn.apache.org/viewcvs?rev=366028&view=rev
Log:
Finished the implementation of MySql support

Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlModelReader.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlPlatform.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlModelReader.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlModelReader.java?rev=366028&r1=366027&r2=366028&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlModelReader.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlModelReader.java Wed
Jan  4 15:33:17 2006
@@ -17,13 +17,9 @@
  */
 
 import java.sql.SQLException;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.List;
 import java.util.Map;
 
 import org.apache.ddlutils.PlatformInfo;
-import org.apache.ddlutils.model.Column;
 import org.apache.ddlutils.model.ForeignKey;
 import org.apache.ddlutils.model.Index;
 import org.apache.ddlutils.model.Table;
@@ -60,88 +56,27 @@
     protected Table readTable(DatabaseMetaDataWrapper metaData, Map values) throws SQLException
     {
         Table table =  super.readTable(metaData, values);
-//        List indexes = new ArrayList();
-//        // this could be optimized, we need to check if an index can be named PRIMARY without
-//        // being a primary key. Taking the safe path for now.
-//        for (int i = 0; i < table.getIndexCount(); i++)
-//        {
-//            Index index = table.getIndex(i);
-//            if ("PRIMARY".equals(index.getName()))
-//            {
-//                for (int c = 0; c < index.getColumnCount(); c++)
-//                {
-//                    String columnName = index.getColumn(c).getName();
-//                    Column column  = table.findColumn(columnName);
-//                    if (column.isPrimaryKey())
-//                    {
-//                        indexes.add(index);
-//                    }
-//                }
-//            }
-//            else
-//            {
-//                for (int f = 0; f < table.getForeignKeyCount(); f++)
-//                {
-//                    ForeignKey fk = table.getForeignKey(f);
-//                    if (fk.getName().equals(index.getName()))
-//                    {
-//                        indexes.add(index);
-//                    }
-//                }
-//            }
-//        }
-//        for (int i = 0; i < indexes.size(); i++)
-//        {
-//            table.removeIndex((Index) indexes.get(i));
-//        }
+
+        determineAutoIncrementFromResultSetMetaData(table, table.getPrimaryKeyColumns());
+        
         return table;
     }
 
     /**
      * {@inheritDoc}
      */
-    protected Column readColumn(DatabaseMetaDataWrapper metaData, Map values) throws SQLException
+    protected boolean isInternalPrimaryKeyIndex(Table table, Index index)
     {
-        Column column = super.readColumn(metaData, values);
-
-        if (column.getTypeCode() == Types.BIT)
-        {
-            // MySql
-        }
-//        if ("".equals(column.getDescription()))
-//        {
-//            column.setDescription(null);
-//        }
-//        if ("".equals(column.getParsedDefaultValue()))
-//        {
-//            column.setDefaultValue(null);
-//        }
-//        if ("auto_increment".equals(column.getDescription()))
-//        {
-//            column.setAutoIncrement(true);
-//        }
-//        switch (column.getTypeCode())
-//        {
-//            case Types.INTEGER:
-//                if ("0".equals(column.getDefaultValue()))
-//                {
-//                    column.setDefaultValue(null);
-//                }
-//            case Types.DOUBLE:
-//                column.setSize(null);
-//                break;
-//        }
-        return column;
+        // MySql defines a unique index "PRIMARY" for primary keys
+        return "PRIMARY".equals(index.getName());
     }
 
     /**
      * {@inheritDoc}
      */
-    protected boolean isInternalPrimaryKeyIndex(Table table, Index index)
+    protected boolean isInternalForeignKeyIndex(Table table, ForeignKey fk, Index index)
     {
-        // MySql defines a unique index "PRIMARY" for primary keys
-        return "PRIMARY".equals(index.getName());
+        // MySql defines a non-unique index of the same name as the fk
+        return new MySqlBuilder(getPlatformInfo()).getForeignKeyName(table, fk).equals(index.getName());
     }
-
-
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlPlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlPlatform.java?rev=366028&r1=366027&r2=366028&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlPlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlPlatform.java Wed Jan
 4 15:33:17 2006
@@ -54,7 +54,7 @@
         // see http://dev.mysql.com/doc/refman/4.1/en/example-auto-increment.html
         info.setSupportingNonPKIdentityColumns(false);
         // MySql returns synthetic default values for pk columns
-        info.setReturningDefaultValueForPrimaryKeys(true);
+        info.setReturningDefaultValueForRequired(true);
         info.setCommentPrefix("#");
         // Double quotes are only allowed for delimiting identifiers if the server SQL mode
includes ANSI_QUOTES 
         info.setDelimiterToken("`");



Mime
View raw message