You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by st...@apache.org on 2019/01/29 13:53:14 UTC

[openjpa] 03/05: OPENJPA-2713 improve MariaDB Dictionary

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 fffc74f0a7f3e387c2cc9826ceabf6a11918468b
Author: Mark Struberg <st...@apache.org>
AuthorDate: Mon Jan 28 13:00:05 2019 +0100

    OPENJPA-2713 improve MariaDB Dictionary
    
    Seems like MariaDB does still have quite a few problems in their JDBC driver.
    I at least tried to iron out new functionality.
---
 .../openjpa/jdbc/kernel/exps/JDBCExpressionFactory.java   |  6 ++----
 .../org/apache/openjpa/jdbc/sql/MariaDBDictionary.java    | 15 ++++++++++++---
 openjpa-project/BUILDING.txt                              | 14 ++++++++++++--
 3 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/JDBCExpressionFactory.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/JDBCExpressionFactory.java
index 04f3a19..ab00787 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/JDBCExpressionFactory.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/JDBCExpressionFactory.java
@@ -301,10 +301,8 @@ public class JDBCExpressionFactory
         String single, String multi, String esc) {
         if (!(v2 instanceof Const))
             throw new UserException(_loc.get("const-only", "matches"));
-        if (esc == null && _type.getMappingRepository().
-                getDBDictionary().requiresSearchStringEscapeForLike == true) {
-            esc = _type.getMappingRepository().
-                getDBDictionary().searchStringEscape;
+        if (esc == null && _type.getMappingRepository().getDBDictionary().requiresSearchStringEscapeForLike) {
+            esc = _type.getMappingRepository().getDBDictionary().searchStringEscape;
         }
         return new MatchesExpression((Val) v1, (Const) v2, single, multi, esc);
     }
diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MariaDBDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MariaDBDictionary.java
index 106bc5b..4443a56 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MariaDBDictionary.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MariaDBDictionary.java
@@ -74,7 +74,7 @@ public class MariaDBDictionary extends DBDictionary {
      * combined <code>DELETE FROM foo, bar, baz</code> syntax.
      * Defaults to false, since this may fail in the presence of InnoDB tables
      * with foreign keys.
-     * @see http://dev.mysql.com/doc/refman/5.0/en/delete.html
+     * @link http://dev.mysql.com/doc/refman/5.0/en/delete.html
      */
     public boolean optimizeMultiTableDeletes = false;
 
@@ -98,6 +98,8 @@ public class MariaDBDictionary extends DBDictionary {
         supportsSelectStartIndex = true;
         supportsSelectEndIndex = true;
 
+        datePrecision = MICRO;
+
         concatenateFunction = "CONCAT({0},{1})";
 
         maxTableNameLength = 64;
@@ -153,11 +155,11 @@ public class MariaDBDictionary extends DBDictionary {
         }));
 
         requiresSearchStringEscapeForLike = true;
+
         // MariaDB requires double-escape for strings
         searchStringEscape = "\\\\";
 
-        typeModifierSet.addAll(Arrays.asList(new String[] { "UNSIGNED",
-            "ZEROFILL" }));
+        typeModifierSet.addAll(Arrays.asList(new String[] { "UNSIGNED", "ZEROFILL" }));
 
         setLeadingDelimiter(DELIMITER_BACK_TICK);
         setTrailingDelimiter(DELIMITER_BACK_TICK);
@@ -186,6 +188,13 @@ public class MariaDBDictionary extends DBDictionary {
         }
 
         supportsXMLColumn = true;
+
+        if (maj > 10 || (maj == 10 && min > 1)) {
+            // MariaDB supports fraction of a second
+            timestampTypeName = "DATETIME{0}";
+            fixedSizeTypeNameSet.remove(timestampTypeName);
+            fractionalTypeNameSet.add(timestampTypeName);
+        }
     }
 
     @Override
diff --git a/openjpa-project/BUILDING.txt b/openjpa-project/BUILDING.txt
index c002b6a..351d380 100644
--- a/openjpa-project/BUILDING.txt
+++ b/openjpa-project/BUILDING.txt
@@ -191,7 +191,7 @@ The generated PDF is available under ./target/docbook/manual.pdf
 
 Running unit tests in the Debugger
 ==================================
-TODO: finish!
+
 By default all tests run against a derby database.
 To run the tests in the debugger simply add the following JVM properties
 
@@ -203,4 +203,14 @@ For running against a MySQL Docker installation:
 
 Running against a PostgreSQL Docker installation:
 
- -ea -Dopenjpa.ConnectionDriverName=org.postgresql.Driver -Dopenjpa.ConnectionURL=jdbc:postgresql:5432//localhost/openjpatst -Dopenjpa.ConnectionUserName=postgres -Dopenjpa.ConnectionPassword=postgres
\ No newline at end of file
+ -ea -Dopenjpa.ConnectionDriverName=org.postgresql.Driver -Dopenjpa.ConnectionURL=jdbc:postgresql:5432//localhost/openjpatst -Dopenjpa.ConnectionUserName=postgres -Dopenjpa.ConnectionPassword=postgres
+
+For running against a MariaDB Docker installation:
+
+ -ea -Dopenjpa.ConnectionDriverName=org.mariadb.jdbc.Driver -Dopenjpa.ConnectionURL=jdbc:mariadb://localhost:3306/openjpatst -Dopenjpa.ConnectionUserName=root -Dopenjpa.ConnectionPassword=openjpatst
+
+TODO: finish!
+
+For starting tests in `openjpa-persistence-jdbc` inside a compiler you can also trigger all the enhancement manually via:
+
+ $> mvn process-test-classes