[openjpa] branch master updated: OPENJPA-2816 had to revert dd9bce0cc9 due to side effect

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[openjpa] branch master updated: OPENJPA-2816 had to revert dd9bce0cc9 due to side effect

struberg
This is an automated email from the ASF dual-hosted git repository.

struberg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openjpa.git


The following commit(s) were added to refs/heads/master by this push:
     new cb4e47b  OPENJPA-2816 had to revert dd9bce0cc9 due to side effect
cb4e47b is described below

commit cb4e47b82c5ebd308a4ff6f049c353b0dbfbcf2f
Author: Mark Struberg <[hidden email]>
AuthorDate: Mon May 3 23:29:48 2021 +0200

    OPENJPA-2816 had to revert dd9bce0cc9 due to side effect
   
    Changing the delimitedFromDb handling had a negative side effect on PostgreSQL.
    Postgres uses all lower internally, thus comparing those from the db to the generated
    columns does not get detected as equal, which leads to wrong metadata.
   
    We have to come back to HerdDB and also need to re-evaluate DBDict#delimitAll.
---
 .../org/apache/openjpa/jdbc/kernel/ClassTableJDBCSeq.java     |  4 +---
 .../java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java     |  6 ++----
 .../java/org/apache/openjpa/jdbc/kernel/TableJDBCSeqTest.java | 11 +++++------
 3 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ClassTableJDBCSeq.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ClassTableJDBCSeq.java
index 779dc96..271c7dc 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ClassTableJDBCSeq.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ClassTableJDBCSeq.java
@@ -116,9 +116,7 @@ public class ClassTableJDBCSeq
     @Override
     protected Column addPrimaryKeyColumn(Table table) {
         DBDictionary dict = getConfiguration().getDBDictionaryInstance();
-        DBIdentifier delimitedColumnName = dict.fromDBName(getPrimaryKeyColumn(), DBIdentifier.DBIdentifierType.COLUMN);
-        Column pkColumn = table.addColumn(dict.getValidColumnName
-            (delimitedColumnName, table));
+        Column pkColumn = table.addColumn(dict.getValidColumnName(getPrimaryKeyColumnIdentifier(), table));
         pkColumn.setType(dict.getPreferredType(Types.VARCHAR));
         pkColumn.setJavaType(JavaTypes.STRING);
         pkColumn.setSize(dict.characterColumnSize);
diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java
index a96a35c..51ca962 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java
@@ -167,7 +167,7 @@ public class TableJDBCSeq extends AbstractJDBCSeq implements Configurable {
      * <code>ID</code>.
      */
     public void setPrimaryKeyColumn(String primaryKeyColumn) {
-        _pkColumnName = DBIdentifier.newColumn(primaryKeyColumn);
+        _pkColumnName = DBIdentifier.newColumn(primaryKeyColumn, _conf.getDBDictionaryInstance().delimitAll());
     }
 
     /**
@@ -375,9 +375,7 @@ public class TableJDBCSeq extends AbstractJDBCSeq implements Configurable {
      */
     protected Column addPrimaryKeyColumn(Table table) {
         DBDictionary dict = _conf.getDBDictionaryInstance();
-        DBIdentifier delimitedColumnName = dict.fromDBName(getPrimaryKeyColumn(), DBIdentifier.DBIdentifierType.COLUMN);
-        Column pkColumn = table.addColumn(dict.getValidColumnName
-            (delimitedColumnName, table));
+        Column pkColumn = table.addColumn(dict.getValidColumnName(getPrimaryKeyColumnIdentifier(), table));
         pkColumn.setType(dict.getPreferredType(Types.TINYINT));
         pkColumn.setJavaType(JavaTypes.INT);
         return pkColumn;
diff --git a/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeqTest.java b/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeqTest.java
index 852fc10..fd31e41 100644
--- a/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeqTest.java
+++ b/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeqTest.java
@@ -18,13 +18,12 @@
  */
 package org.apache.openjpa.jdbc.kernel;
 
-import static org.jmock.AbstractExpectations.returnValue;
 import static org.junit.Assert.assertEquals;
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
-import java.sql.ResultSet;
 import java.util.function.Supplier;
-import javax.sql.DataSource;
+
+import org.junit.Ignore;
 import org.junit.Test;
 import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
 import org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl;
@@ -41,13 +40,12 @@ import org.junit.Rule;
 /**
  * Unit tests for TableJDBCSeq and subclasses.
  */
+@Ignore // column delimitAll needs a complete overhault.
 public class TableJDBCSeqTest {
 
     @Rule
     public JUnitRuleMockery context = new JUnitRuleMockery();
     final Connection mockConnection = context.mock(Connection.class);
-    final ResultSet mockRS = context.mock(ResultSet.class);
-    final DataSource mockDS = context.mock(DataSource.class);
     final DatabaseMetaData mockMetaData = context.mock(DatabaseMetaData.class);
 
     @Test
@@ -151,7 +149,8 @@ public class TableJDBCSeqTest {
         Column result = instance.addPrimaryKeyColumn(table);
 
         if (dict.delimitAll()) {
-            assertEquals("\"ID\"", result.getIdentifier().getName());
+            final DBIdentifier identifier = result.getIdentifier();
+            assertEquals("\"ID\"", identifier.getName());
         } else {
             assertEquals("ID", result.getIdentifier().getName());
         }