OPENJPA-1132: Use MySQL-specific syntax for dropping foreign and primary keys.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@784402 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Milosz Tylenda 2009-06-13 14:42:45 +00:00
parent 888ddb83c0
commit 5d1bd85ca8
1 changed files with 32 additions and 0 deletions

View File

@ -30,6 +30,7 @@ import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
import org.apache.openjpa.jdbc.kernel.JDBCStore;
import org.apache.openjpa.jdbc.kernel.exps.FilterValue;
import org.apache.openjpa.jdbc.schema.Column;
import org.apache.openjpa.jdbc.schema.ForeignKey;
import org.apache.openjpa.jdbc.schema.Index;
import org.apache.openjpa.jdbc.schema.PrimaryKey;
import org.apache.openjpa.jdbc.schema.Table;
@ -207,6 +208,37 @@ public class MySQLDictionary
+ getFullName(index.getTable(), false) };
}
/**
* Return <code>ALTER TABLE &lt;table name&gt; DROP PRIMARY KEY</code>.
*/
@Override
public String[] getDropPrimaryKeySQL(PrimaryKey pk) {
if (pk.getName() == null)
return new String[0];
return new String[]{ "ALTER TABLE "
+ getFullName(pk.getTable(), false)
+ " DROP PRIMARY KEY" };
}
/**
* Return <code>ALTER TABLE &lt;table name&gt; DROP FOREIGN KEY
* &lt;fk name&gt;</code>.
*/
@Override
public String[] getDropForeignKeySQL(ForeignKey fk, Connection conn) {
if (fk.getName() == null) {
String fkName = fk.loadNameFromDB(this,conn);
String[] retVal = (fkName == null) ? new String[0] :
new String[]{ "ALTER TABLE "
+ getFullName(fk.getTable(), false)
+ " DROP FOREIGN KEY " + fkName };
return retVal;
}
return new String[]{ "ALTER TABLE "
+ getFullName(fk.getTable(), false)
+ " DROP FOREIGN KEY " + fk.getName() };
}
public String[] getAddPrimaryKeySQL(PrimaryKey pk) {
String[] sql = super.getAddPrimaryKeySQL(pk);