db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r529502 - in /db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase: InterbaseBuilder.java InterbaseModelReader.java
Date Tue, 17 Apr 2007 06:47:59 GMT
Author: tomdz
Date: Mon Apr 16 23:47:59 2007
New Revision: 529502

URL: http://svn.apache.org/viewvc?view=rev&rev=529502
Log:
Fixed a bug in the foreign key reading in the Interbase platform

Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseModelReader.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseBuilder.java?view=diff&rev=529502&r1=529501&r2=529502
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseBuilder.java
(original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseBuilder.java
Mon Apr 16 23:47:59 2007
@@ -128,7 +128,7 @@
         printEndOfStatement();
 
         print("CREATE TRIGGER ");
-        printIdentifier(getConstraintName("trg", table, column.getName(), null));
+        printIdentifier(getTriggerName(table, column));
         print(" FOR ");
         printlnIdentifier(getTableName(table));
         println("ACTIVE BEFORE INSERT POSITION 0 AS");
@@ -151,12 +151,24 @@
     private void writeAutoIncrementDropStmts(Table table, Column column) throws IOException
     {
         print("DROP TRIGGER ");
-        printIdentifier(getConstraintName("trg", table, column.getName(), null));
+        printIdentifier(getTriggerName(table, column));
         printEndOfStatement();
 
         print("DROP GENERATOR ");
         printIdentifier(getGeneratorName(table, column));
         printEndOfStatement();
+    }
+
+    /**
+     * Determines the name of the trigger for an auto-increment column.
+     * 
+     * @param table  The table
+     * @param column The auto-increment column
+     * @return The trigger name
+     */
+    protected String getTriggerName(Table table, Column column)
+    {
+        return getConstraintName("trg", table, column.getName(), null);
     }
 
     /**

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseModelReader.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseModelReader.java?view=diff&rev=529502&r1=529501&r2=529502
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseModelReader.java
(original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseModelReader.java
Mon Apr 16 23:47:59 2007
@@ -31,6 +31,7 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.commons.collections.map.ListOrderedMap;
 import org.apache.ddlutils.Platform;
 import org.apache.ddlutils.model.Column;
 import org.apache.ddlutils.model.ForeignKey;
@@ -320,6 +321,53 @@
             }
         }
         return pks;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected Collection readForeignKeys(DatabaseMetaDataWrapper metaData, String tableName)
throws SQLException
+    {
+        Map       fks    = new ListOrderedMap();
+        ResultSet fkData = null;
+
+        try
+        {
+            if (getPlatform().isDelimitedIdentifierModeOn())
+            {
+                // Jaybird has a problem when delimited identifiers are used as
+                // it is not able to find the foreign key info for the table
+                // So we have to filter manually below
+                fkData = metaData.getForeignKeys(getDefaultTablePattern());
+                while (fkData.next())
+                {
+                    Map values = readColumns(fkData, getColumnsForFK());
+    
+                    if (tableName.equals(values.get("FKTABLE_NAME")))
+                    {
+                        readForeignKey(metaData, values, fks);
+                    }
+                }
+            }
+            else
+            {
+                fkData = metaData.getForeignKeys(tableName);
+                while (fkData.next())
+                {
+                    Map values = readColumns(fkData, getColumnsForFK());
+    
+                    readForeignKey(metaData, values, fks);
+                }
+            }
+        }
+        finally
+        {
+            if (fkData != null)
+            {
+                fkData.close();
+            }
+        }
+        return fks.values();
     }
 
     /**



Mime
View raw message