[openjpa] branch master updated (d8bb07f -> 8f959cc)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[openjpa] branch master updated (d8bb07f -> 8f959cc)

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

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


    from d8bb07f  OPENJPA-2868 update reserved column words for Derby
     new 90ba3b8  fix Spec compat tests to work with all DBs
     new 8f959cc  OPENJPA-2868 update reserved column names for H2

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/org/apache/openjpa/jdbc/sql/H2Dictionary.java   |  9 ++++++---
 .../compat/TestContainerSpecCompatibilityOptions.java    |  8 +++++++-
 .../persistence/compat/TestSpecCompatibilityOptions.java | 11 ++++++++---
 .../persistence/test/AbstractPersistenceTestCase.java    | 16 ++++++++++++----
 4 files changed, 33 insertions(+), 11 deletions(-)
Reply | Threaded
Open this post in threaded view
|

[openjpa] 01/02: fix Spec compat tests to work with all DBs

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

commit 90ba3b8d5df3ec2843e85d85edf258970dd6900b
Author: Mark Struberg <[hidden email]>
AuthorDate: Sun May 2 15:36:05 2021 +0200

    fix Spec compat tests to work with all DBs
   
    test should rely on whether KEY is a reserved word or not.
---
 .../compat/TestContainerSpecCompatibilityOptions.java    |  8 +++++++-
 .../persistence/compat/TestSpecCompatibilityOptions.java | 11 ++++++++---
 .../persistence/test/AbstractPersistenceTestCase.java    | 16 ++++++++++++----
 3 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compat/TestContainerSpecCompatibilityOptions.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compat/TestContainerSpecCompatibilityOptions.java
index 4a3e1cc..f5e7a54 100644
--- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compat/TestContainerSpecCompatibilityOptions.java
+++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compat/TestContainerSpecCompatibilityOptions.java
@@ -419,7 +419,13 @@ public class TestContainerSpecCompatibilityOptions
             // trigger table creation
             em.getTransaction().begin();
             em.getTransaction().commit();
-            assertSQLFragnments(sql, "CREATE TABLE C_U1M_Map_FK", "Uni1MFK_ID", "KEY0");
+
+            // on some databases KEY is a forbidden name for columns.
+            String keyColumn = getDbDictioary(emf).getInvalidColumnWordSet().contains("KEY")
+                    ? "KEY0"
+                    : "KEY";
+            assertSQLFragnments(sql, "CREATE TABLE C_U1M_Map_FK", "Uni1MFK_ID", keyColumn);
+
             assertSQLFragnments(sql, "CREATE TABLE Bi1M_Map_JT_C", "B_ID", "C_ID");
             assertSQLFragnments(sql, "CREATE TABLE C_U1M_Map_RelKey_FK", "Uni1MFK_ID");
             assertSQLFragnments(sql, "CREATE TABLE Bi1M_Map_RelKey_JT_C", "B_ID", "C_ID");
diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compat/TestSpecCompatibilityOptions.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compat/TestSpecCompatibilityOptions.java
index 1ded560..1d8b5b4 100644
--- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compat/TestSpecCompatibilityOptions.java
+++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/compat/TestSpecCompatibilityOptions.java
@@ -410,7 +410,13 @@ extends AbstractCachedEMFTestCase {
             // trigger table creation
             em.getTransaction().begin();
             em.getTransaction().commit();
-            assertSQLFragnments(sql, "CREATE TABLE C_U1M_Map_FK", "Uni1MFK_ID", "KEY0");
+
+            // on some databases KEY is a forbidden name for columns.
+            String keyColumn = getDbDictioary(emf).getInvalidColumnWordSet().contains("KEY")
+                            ? "KEY0"
+                            : "KEY";
+            assertSQLFragnments(sql, "CREATE TABLE C_U1M_Map_FK", "Uni1MFK_ID", keyColumn);
+
             assertSQLFragnments(sql, "CREATE TABLE Bi1M_Map_JT_C", "B_ID", "C_ID");
             assertSQLFragnments(sql, "CREATE TABLE C_U1M_Map_RelKey_FK", "Uni1MFK_ID");
             assertSQLFragnments(sql, "CREATE TABLE Bi1M_Map_RelKey_JT_C", "B_ID", "C_ID");
@@ -867,8 +873,7 @@ extends AbstractCachedEMFTestCase {
         map.put("openjpa.MetaDataFactory", "jpa(Types=" + buf.toString() + oldValue + ")");
         return (OpenJPAEntityManagerFactorySPI)OpenJPAPersistence.
                 createEntityManagerFactory("persistence_2_0",
-                    "org/apache/openjpa/persistence/compat/" +
-                    "persistence_2_0.xml", map);
+                    "org/apache/openjpa/persistence/compat/persistence_2_0.xml", map);
     }
 
     void assertSQLFragnments(List<String> list, String... keys) {
diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/AbstractPersistenceTestCase.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/AbstractPersistenceTestCase.java
index 4e5e245..06ae645 100644
--- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/AbstractPersistenceTestCase.java
+++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/AbstractPersistenceTestCase.java
@@ -38,10 +38,13 @@ import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
 import javax.persistence.Persistence;
 
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
+import org.apache.openjpa.jdbc.sql.DBDictionary;
 import org.apache.openjpa.kernel.AbstractBrokerFactory;
 import org.apache.openjpa.kernel.Broker;
 import org.apache.openjpa.meta.ClassMetaData;
 import org.apache.openjpa.persistence.JPAFacadeHelper;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
 import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
 import org.apache.openjpa.persistence.OpenJPAPersistence;
 
@@ -271,10 +274,10 @@ public abstract class AbstractPersistenceTestCase extends TestCase {
             if (b != null && !b.isClosed()) {
                 EntityManager em = JPAFacadeHelper.toEntityManager(b);
                 if( em.getTransaction().isActive() ) {
-                 try {
- em.getTransaction().rollback();
- } catch (Exception e) {
- }
+                    try {
+                        em.getTransaction().rollback();
+                    } catch (Exception e) {
+                    }
                 }
                 closeEM(em);
             }
@@ -355,6 +358,11 @@ public abstract class AbstractPersistenceTestCase extends TestCase {
         }
     }
 
+    protected DBDictionary getDbDictioary(EntityManagerFactory emf) {
+        return ((JDBCConfiguration)((OpenJPAEntityManagerFactory) emf).getConfiguration()).getDBDictionaryInstance();
+    }
+
+
     /**
      * Return the entity name for the given type.
      */
Reply | Threaded
Open this post in threaded view
|

[openjpa] 02/02: OPENJPA-2868 update reserved column names for H2

struberg
In reply to this post by 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

commit 8f959cc3a543cc414e03d9f25e5a270396f943aa
Author: Mark Struberg <[hidden email]>
AuthorDate: Sun May 2 15:37:06 2021 +0200

    OPENJPA-2868 update reserved column names for H2
---
 .../src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java  | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java
index a489d11..ae2ac0b 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java
@@ -126,10 +126,13 @@ public class H2Dictionary extends DBDictionary {
 
         // reservedWordSet subset that CANNOT be used as valid column names
         // (i.e., without surrounding them with double-quotes)
-        invalidColumnWordSet.addAll(Arrays.asList(new String[]{
-            "ORDER", "KEY",
+        // generated at 2021-05-02T14:32:50.704 via org.apache.openjpa.reservedwords.ReservedWordsIT
+        invalidColumnWordSet.addAll(Arrays.asList(new String[] {
+            "CHECK", "CONSTRAINT", "CROSS", "CURRENT_DATE", "CURRENT_TIME", "CURRENT_TIMESTAMP", "DISTINCT", "END-EXEC",
+            "EXCEPT", "EXISTS", "FALSE", "FETCH", "FOR", "FOREIGN", "FROM", "FULL", "GROUP", "HAVING", "INNER", "INTERSECT",
+            "IS", "JOIN", "LIKE", "LIMIT", "MINUS", "NATURAL", "NOT", "NULL", "OFFSET", "ON", "ORDER", "PRIMARY", "ROWNUM",
+            "SELECT", "SYSDATE", "TRUE", "UNION", "UNIQUE", "WHERE", "WITH",
         }));
-
     }
 
     @Override