db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r405892 - /db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java
Date Fri, 12 May 2006 21:48:56 GMT
Author: tomdz
Date: Fri May 12 14:48:56 2006
New Revision: 405892

URL: http://svn.apache.org/viewcvs?rev=405892&view=rev
Log:
Added a warning when a foreign key without a name is encountered

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

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=405892&r1=405891&r2=405892&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 Fri May 12 14:48:56
2006
@@ -2253,9 +2253,10 @@
      */
     public String getForeignKeyName(Table table, ForeignKey fk)
     {
-        String fkName = fk.getName();
+        String  fkName    = fk.getName();
+        boolean needsName = (fkName == null) || (fkName.length() == 0);
 
-        if ((fkName == null) || (fkName.length() == 0))
+        if (needsName)
         {
             StringBuffer name = new StringBuffer();
     
@@ -2267,7 +2268,15 @@
             name.append(fk.getForeignTableName());
             fkName = getConstraintName(null, table, "FK", name.toString());
         }
-        return shortenName(fkName, getPlatformInfo().getMaxIdentifierLength());
+        fkName = shortenName(fkName, getPlatformInfo().getMaxIdentifierLength());
+
+        if (needsName)
+        {
+            _log.warn("Encountered a foreign key in table " + table.getName() +" that has
no name." +
+                      "DdlUtils will use the auto-generated and shortened name " + fkName
+ "instead.");
+        }
+
+        return fkName;
     }
 
     /**



Mime
View raw message