Merge pull request #75 from eolivelli/fix/OPENJPA-2832

OPENJPA-2832 DROP COLUMN does not use delimiters and always add double quotes
diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
index 7a86095..0776702 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
@@ -3840,7 +3840,7 @@
             return new String[0];
         return new String[]{ "ALTER TABLE "
             + getFullName(column.getTable(), false)
-            + " DROP COLUMN " + column };
+            + " DROP COLUMN " + toDBName(column.getIdentifier()) };
     }
 
     /**
diff --git a/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/TestDBDictionaryGeneratedSQL.java b/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/TestDBDictionaryGeneratedSQL.java
index 262b91b..33254dc 100644
--- a/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/TestDBDictionaryGeneratedSQL.java
+++ b/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/TestDBDictionaryGeneratedSQL.java
@@ -25,6 +25,7 @@
 import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
 import org.apache.openjpa.jdbc.identifier.DBIdentifier;
 import org.apache.openjpa.jdbc.identifier.DBIdentifierUtilImpl;
+import org.apache.openjpa.jdbc.schema.Column;
 import org.apache.openjpa.jdbc.schema.Table;
 import org.apache.openjpa.util.UserException;
 import org.jmock.Expectations;
@@ -192,4 +193,35 @@
         assertTrue(sqls[0].contains("NameIsRight"));
         assertTrue(sqls[0].contains("schema"));
     }
+
+    @Test
+    public void testDropColumnWithDelimiters() {
+        final JDBCConfiguration mockConfiguration = context.mock(JDBCConfiguration.class);
+        final DBIdentifierUtilImpl idImpl = new DBIdentifierUtilImpl();
+
+        context.checking(new Expectations()
+        {
+            {
+                allowing(mockConfiguration).getIdentifierUtilInstance();
+                will(returnValue(idImpl));
+
+                allowing(mockConfiguration);
+            }
+        });
+
+        DBDictionary dict = new DBDictionary();
+        dict.setDelimitIdentifiers(true);
+        dict.setSupportsDelimitedIdentifiers(true);
+        dict.setLeadingDelimiter("`");
+        dict.setTrailingDelimiter("`");
+        dict.setConfiguration(mockConfiguration);
+        Table table = new Table();
+        table.setIdentifier(dict.fromDBName("NameIsRight", DBIdentifier.DBIdentifierType.TABLE));
+
+        Column column = new Column(dict.fromDBName("MyColumn", DBIdentifier.DBIdentifierType.COLUMN), table);
+
+        String[] sqls = dict.getDropColumnSQL(column);
+        assertEquals(1, sqls.length);
+        assertEquals(sqls[0], "ALTER TABLE `NameIsRight` DROP COLUMN `MyColumn`");
+    }
 }