[openjpa] branch master updated (7d3c89c -> d8bb07f)

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

[openjpa] branch master updated (7d3c89c -> d8bb07f)

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 7d3c89c  OPENJPA-2867 add a way to test reserved words
     new 188ed23  OPENJPA-2867 generated pastable java code
     new d8bb07f  OPENJPA-2868 update reserved column words for Derby

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:
 .../apache/openjpa/jdbc/sql/DerbyDictionary.java   | 58 ++++++++++------------
 .../openjpa/reservedwords/ReservedWordsIT.java     | 27 ++++++++--
 .../openjpa/reservedwords/sql_reserved_words.txt   | 11 ++++
 3 files changed, 58 insertions(+), 38 deletions(-)
Reply | Threaded
Open this post in threaded view
|

[openjpa] 01/02: OPENJPA-2867 generated pastable java code

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 188ed235dc7c1e9db5b5f009d297fb297b4af1cf
Author: Mark Struberg <[hidden email]>
AuthorDate: Sun May 2 14:11:41 2021 +0200

    OPENJPA-2867 generated pastable java code
   
    also add more reserved words
---
 .../openjpa/reservedwords/ReservedWordsIT.java     | 27 ++++++++++++++++++----
 .../openjpa/reservedwords/sql_reserved_words.txt   | 11 +++++++++
 2 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/reservedwords/ReservedWordsIT.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/reservedwords/ReservedWordsIT.java
index 90b300d..6effbdf 100644
--- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/reservedwords/ReservedWordsIT.java
+++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/reservedwords/ReservedWordsIT.java
@@ -27,6 +27,7 @@ import org.apache.openjpa.persistence.test.AbstractPersistenceTestCase;
 import javax.persistence.EntityManager;
 import javax.persistence.Query;
 import java.io.*;
+import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -83,14 +84,30 @@ public class ReservedWordsIT extends AbstractPersistenceTestCase {
         Log log = getLog();
 
         try (OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("target/reserved_words_" +
-                dict.getClass().getSimpleName() + ".properties"))) {
-            String msg = "# FOUND " + reservedColumnWords.size() + " RESERVED WORDS for Dictionary " + dict.getClass().getName();
-            log.info(msg);
-            osw.append(msg).append('\n');
+                dict.getClass().getSimpleName() + ".java"))) {
+            log.info("FOUND " + reservedColumnWords.size() + " RESERVED WORDS for Dictionary " + dict.getClass().getName());
+            osw.append(
+                    "// reservedWordSet subset that CANNOT be used as valid column names\n" +
+                    "// (i.e., without surrounding them with double-quotes)\n" +
+                    "// generated at " + LocalDateTime.now() + " via " + ReservedWordsIT.class.getName() + "\n" +
+                    "invalidColumnWordSet.addAll(Arrays.asList(new String[] {\n");
+            StringBuilder sb = new StringBuilder();
+            sb.append("    ");
             for (String reservedColumnWord : reservedColumnWords) {
                 log.info(reservedColumnWord);
-                osw.append(reservedColumnWord).append('\n');
+                sb.append('"').append(reservedColumnWord).append("\", ");
+                if (sb.length() > 110) {
+                    osw.append(sb.toString().trim()).append('\n');
+                    sb.setLength(0);
+                }
+            }
+
+            // also add the rest if any
+            if (sb.length() > 0) {
+                osw.append(sb.toString().trim()).append('\n');
             }
+
+            osw.append("}));");
             osw.flush();
         }
         log.info("******* END RESERVED WORDS *******");
diff --git a/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/reservedwords/sql_reserved_words.txt b/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/reservedwords/sql_reserved_words.txt
index 487e0ff..0504b78 100644
--- a/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/reservedwords/sql_reserved_words.txt
+++ b/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/reservedwords/sql_reserved_words.txt
@@ -296,6 +296,7 @@ G
 GENERAL
 GENERATED
 GET
+GETCURRENTCONNECTION
 GLOBAL
 GO
 GOTO
@@ -411,6 +412,7 @@ LONGTEXT
 LOOP
 LOW_PRIORITY
 LOWER
+LTRIM
 M
 MAP
 MATCH
@@ -484,6 +486,7 @@ NULLIF
 NULLS
 NUMBER
 NUMERIC
+NVARCHAR
 OBJECT
 OCTET_LENGTH
 OCTETS
@@ -633,6 +636,8 @@ ROWGUIDCOL
 ROWID
 ROWNUM
 ROWS
+ROW_NUMBER
+RTRIM
 RULE
 SAVE
 SAVEPOINT
@@ -719,6 +724,7 @@ STYLE
 SUBCLASS_ORIGIN
 SUBLIST
 SUBMULTISET
+SUBSTR
 SUBSTRING
 SUCCESSFUL
 SUM
@@ -838,6 +844,11 @@ WORK
 WRITE
 WRITETEXT
 X509
+XML
+XMLEXISTS
+XMLPARSE
+XMLQUERY
+XMLSERIALIZE
 XOR
 YEAR
 YEAR_MONTH
Reply | Threaded
Open this post in threaded view
|

[openjpa] 02/02: OPENJPA-2868 update reserved column words for Derby

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 d8bb07fe86f61a8d62c8701e425383d0cc3ba545
Author: Mark Struberg <[hidden email]>
AuthorDate: Sun May 2 14:31:17 2021 +0200

    OPENJPA-2868 update reserved column words for Derby
---
 .../apache/openjpa/jdbc/sql/DerbyDictionary.java   | 58 ++++++++++------------
 1 file changed, 25 insertions(+), 33 deletions(-)

diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DerbyDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DerbyDictionary.java
index 63b996e..61b119c 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DerbyDictionary.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DerbyDictionary.java
@@ -84,40 +84,32 @@ public class DerbyDictionary
 
         // reservedWordSet subset that CANNOT be used as valid column names
         // (i.e., without surrounding them with double-quotes)
+        // generated at 2021-05-02T14:07:25.218 via org.apache.openjpa.reservedwords.ReservedWordsIT
         invalidColumnWordSet.addAll(Arrays.asList(new String[] {
-            "ADD", "ALL", "ALLOCATE", "ALTER", "AND", "ANY", "ARE", "AS", "ASC",
-            "ASSERTION", "AT", "AUTHORIZATION", "AVG", "BEGIN", "BETWEEN",
-            "BIT", "BOOLEAN", "BOTH", "BY", "CALL", "CASCADE", "CASCADED",
-            "CASE", "CAST", "CHAR", "CHARACTER", "CHARACTER_LENGTH", "CHECK",
-            "CLOSE", "COALESCE", "COLLATE", "COLLATION", "COLUMN", "COMMIT", "CONNECT",
-            "CONNECTION", "CONSTRAINT", "CONSTRAINTS", "CONTINUE", "CONVERT",
-            "CORRESPONDING", "CREATE", "CURRENT", "CURRENT_DATE", "CURRENT_ROLE",
-            "CURRENT_TIME", "CURRENT_TIMESTAMP", "CURRENT_USER", "CURSOR",
-            "DEALLOCATE", "DEC", "DECIMAL", "DECLARE", "DEFAULT", "DEFERRABLE",
-            "DEFERRED", "DELETE", "DESC", "DESCRIBE", "DIAGNOSTICS",
-            "DISCONNECT", "DISTINCT", "DOUBLE", "DROP", "ELSE", "END",
-            "END-EXEC", "ESCAPE", "EXCEPT", "EXCEPTION", "EXEC", "EXECUTE",
-            "EXISTS", "EXPLAIN", "EXTERNAL", "FALSE", "FETCH", "FIRST", "FLOAT",
-            "FOR", "FOREIGN", "FOUND", "FROM", "FULL", "FUNCTION", "GET",
-            "GETCURRENTCONNECTION", "GLOBAL", "GO", "GOTO", "GRANT", "GROUP", "HAVING", "HOUR",
-            "IDENTITY", "IMMEDIATE", "IN", "INDICATOR", "INITIALLY", "INNER",
-            "INOUT", "INPUT", "INSENSITIVE", "INSERT", "INT", "INTEGER",
-            "INTERSECT", "INTO", "IS", "ISOLATION", "JOIN", "KEY", "LAST",
-            "LEADING", "LEFT", "LIKE", "LOWER", "LTRIM", "MATCH", "MAX", "MIN",
-            "MINUTE", "NATIONAL", "NATURAL", "NCHAR", "NEXT", "NO", "NONE", "NOT",
-            "NULL", "NULLIF", "NUMERIC", "NVARCHAR", "OF", "ON", "ONLY", "OPEN",
-            "OPTION", "OR", "ORDER", "OUT", "OUTER", "OUTPUT", "OVER", "OVERLAPS",
-            "PAD", "PARTIAL", "PREPARE", "PRESERVE", "PRIMARY", "PRIOR",
-            "PRIVILEGES", "PROCEDURE", "PUBLIC", "READ", "REAL", "REFERENCES",
-            "RELATIVE", "RESTRICT", "REVOKE", "RIGHT", "ROLLBACK", "ROWS",
-            "ROW_NUMBER", "RTRIM", "SCHEMA", "SCROLL", "SECOND", "SELECT", "SESSION_USER",
-            "SET", "SMALLINT", "SOME", "SPACE", "SQL", "SQLCODE", "SQLERROR",
-            "SQLSTATE", "SUBSTR", "SUBSTRING", "SUM", "SYSTEM_USER", "TABLE",
-            "TEMPORARY", "TIMEZONE_HOUR", "TIMEZONE_MINUTE", "TO", "TRAILING",
-            "TRANSACTION", "TRANSLATE", "TRANSLATION", "TRIM", "TRUE", "UNION",
-            "UNIQUE", "UNKNOWN", "UPDATE", "UPPER", "USER", "USING", "VALUES",
-            "VARCHAR", "VARYING", "VIEW", "WHENEVER", "WHERE", "WITH", "WORK",
-            "WRITE", "XML", "XMLEXISTS", "XMLPARSE", "XMLQUERY", "XMLSERIALIZE", "YEAR",
+            "ADD", "ALL", "ALLOCATE", "ALTER", "AND", "ANY", "ARE", "AS", "ASC", "ASSERTION", "AT", "AUTHORIZATION", "AVG",
+            "BEGIN", "BETWEEN", "BIGINT", "BIT", "BOOLEAN", "BOTH", "BY", "CALL", "CASCADE", "CASCADED", "CASE", "CAST", "CHAR",
+            "CHARACTER", "CHARACTER_LENGTH", "CHECK", "CLOSE", "COLLATE", "COLLATION", "COLUMN", "COMMIT", "CONNECT", "CONNECTION",
+            "CONSTRAINT", "CONSTRAINTS", "CONTINUE", "CONVERT", "CORRESPONDING", "CREATE", "CROSS", "CURRENT", "CURRENT_DATE",
+            "CURRENT_ROLE", "CURRENT_TIME", "CURRENT_TIMESTAMP", "CURRENT_USER", "CURSOR", "DEALLOCATE", "DEC", "DECIMAL",
+            "DECLARE", "DEFAULT", "DEFERRABLE", "DEFERRED", "DEFINER", "DELETE", "DESC", "DESCRIBE", "DETERMINISTIC", "DIAGNOSTICS",
+            "DISCONNECT", "DISTINCT", "DOUBLE", "DROP", "ELSE", "END", "END-EXEC", "ESCAPE", "EXCEPT", "EXCEPTION", "EXEC",
+            "EXECUTE", "EXISTS", "EXPLAIN", "EXTERNAL", "FALSE", "FETCH", "FIRST", "FLOAT", "FOR", "FOREIGN", "FOUND", "FROM",
+            "FULL", "FUNCTION", "GET", "GETCURRENTCONNECTION", "GLOBAL", "GO", "GOTO", "GRANT", "GROUP", "HAVING", "HOUR",
+            "IDENTITY", "IMMEDIATE", "IN", "INDICATOR", "INITIALLY", "INNER", "INOUT", "INPUT", "INSENSITIVE", "INSERT", "INT",
+            "INTEGER", "INTERSECT", "INTO", "INVOKER", "IS", "ISOLATION", "JOIN", "KEY", "LAST", "LEADING", "LEFT", "LIKE",
+            "LOWER", "LTRIM", "MATCH", "MAX", "MIN", "MINUTE", "NATIONAL", "NATURAL", "NCHAR", "NEXT", "NO", "NONE", "NOT",
+            "NULL", "NULLIF", "NUMERIC", "NVARCHAR", "OF", "ON", "ONLY", "OPEN", "OPTION", "OR", "ORDER", "OUT", "OUTER", "OUTPUT",
+            "OVERLAPS", "PAD", "PARTIAL", "PREPARE", "PRESERVE", "PRIMARY", "PRIOR", "PRIVILEGES", "PROCEDURE", "PUBLIC", "READ",
+            "REAL", "REFERENCES", "RELATIVE", "RESTRICT", "REVOKE", "RIGHT", "ROLLBACK", "ROWS", "RTRIM", "SCHEMA", "SCROLL",
+            "SECOND", "SELECT", "SESSION_USER", "SET", "SMALLINT", "SOME", "SPACE", "SQL", "SQLCODE", "SQLERROR", "SQLSTATE",
+            "SUBSTR", "SUBSTRING", "SUM", "SYSTEM_USER", "TABLE", "TEMPORARY", "TIMEZONE_HOUR", "TIMEZONE_MINUTE", "TO", "TRAILING",
+            "TRANSACTION", "TRANSLATE", "TRANSLATION", "TRIM", "TRUE", "UNION", "UNIQUE", "UNKNOWN", "UPDATE", "UPPER", "USER",
+            "USING", "VALUES", "VARCHAR", "VARYING", "VIEW", "WHENEVER", "WHERE", "WINDOW", "WITH", "WORK", "WRITE", "XML",
+            "XMLEXISTS", "XMLPARSE", "XMLQUERY", "XMLSERIALIZE", "YEAR",
+            // end generated.
+            // the following keywords used to be defined as reserved words in the past, but now seem to work
+            // we still add them for compat reasons
+            "COALESCE", "OVER", "ROW_NUMBER",
         }));
     }