Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.net4j.db.h2/src/org/eclipse/net4j/db/h2/H2Adapter.java4
-rw-r--r--plugins/org.eclipse.net4j.db.mysql/src/org/eclipse/net4j/db/mysql/MYSQLAdapter.java7
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java3
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java15
4 files changed, 21 insertions, 8 deletions
diff --git a/plugins/org.eclipse.net4j.db.h2/src/org/eclipse/net4j/db/h2/H2Adapter.java b/plugins/org.eclipse.net4j.db.h2/src/org/eclipse/net4j/db/h2/H2Adapter.java
index a04e5657fa..032b0b8466 100644
--- a/plugins/org.eclipse.net4j.db.h2/src/org/eclipse/net4j/db/h2/H2Adapter.java
+++ b/plugins/org.eclipse.net4j.db.h2/src/org/eclipse/net4j/db/h2/H2Adapter.java
@@ -100,9 +100,9 @@ public class H2Adapter extends DBAdapter
}
@Override
- public String sqlRenameColumn(String table, String from, String to)
+ public String sqlRenameField(IDBField field, String oldName)
{
- return "ALTER TABLE " + table + " ALTER COLUMN " + from + " RENAME TO " + to;
+ return "ALTER TABLE " + field.getTable() + " ALTER COLUMN " + oldName + " RENAME TO " + field;
}
/**
diff --git a/plugins/org.eclipse.net4j.db.mysql/src/org/eclipse/net4j/db/mysql/MYSQLAdapter.java b/plugins/org.eclipse.net4j.db.mysql/src/org/eclipse/net4j/db/mysql/MYSQLAdapter.java
index 2c5f603b43..b96818b5b6 100644
--- a/plugins/org.eclipse.net4j.db.mysql/src/org/eclipse/net4j/db/mysql/MYSQLAdapter.java
+++ b/plugins/org.eclipse.net4j.db.mysql/src/org/eclipse/net4j/db/mysql/MYSQLAdapter.java
@@ -160,4 +160,11 @@ public class MYSQLAdapter extends DBAdapter
{
return "23000".equals(ex.getSQLState());
}
+
+ @Override
+ public String sqlRenameField(IDBField field, String oldName)
+ {
+ return "ALTER TABLE " + field.getTable() + " CHANGE COLUMN " + oldName + " TO " + field + " "
+ + createFieldDefinition(field);
+ }
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java
index f5ec41705e..5d73ba2e2a 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java
@@ -11,6 +11,7 @@
*/
package org.eclipse.net4j.db;
+import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.internal.db.DBAdapterRegistry;
import org.eclipse.net4j.spi.db.DBAdapter;
@@ -102,5 +103,5 @@ public interface IDBAdapter
/**
* @since 4.2
*/
- public String sqlRenameColumn(String table, String from, String to);
+ public String sqlRenameField(IDBField field, String oldName);
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java
index 6da0851b62..e1405f1bca 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java
@@ -469,7 +469,10 @@ public abstract class DBAdapter implements IDBAdapter
}
}
- private String[] createFieldDefinitions(IDBTable table)
+ /**
+ * @since 4.2
+ */
+ protected String[] createFieldDefinitions(IDBTable table)
{
IDBField[] fields = table.getFields();
int fieldCount = fields.length;
@@ -506,7 +509,10 @@ public abstract class DBAdapter implements IDBAdapter
}
}
- private void appendFieldDefs(Appendable appendable, IDBTable table, String[] defs)
+ /**
+ * @since 4.2
+ */
+ protected void appendFieldDefs(Appendable appendable, IDBTable table, String[] defs)
{
try
{
@@ -519,7 +525,6 @@ public abstract class DBAdapter implements IDBAdapter
appendable.append(", "); //$NON-NLS-1$
}
- // String fieldName = mangleFieldName(field.getName(), 0);
String fieldName = field.getName();
appendable.append(fieldName);
appendable.append(" "); //$NON-NLS-1$
@@ -559,9 +564,9 @@ public abstract class DBAdapter implements IDBAdapter
/**
* @since 4.2
*/
- public String sqlRenameColumn(String table, String from, String to)
+ public String sqlRenameField(IDBField field, String oldName)
{
- return "ALTER TABLE " + table + " RENAME COLUMN " + from + " TO " + to;
+ return "ALTER TABLE " + field.getTable() + " RENAME COLUMN " + oldName + " TO " + field;
}
/**

Back to the top