mirror of https://github.com/apache/openjpa.git
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:
parent
888ddb83c0
commit
5d1bd85ca8
|
@ -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 <table name> 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 <table name> DROP FOREIGN KEY
|
||||
* <fk name></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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue