openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject [openjpa] branch master updated: fix a test to also work with MSSQL
Date Wed, 31 Mar 2021 19:40:40 GMT
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 f187178  fix a test to also work with MSSQL
f187178 is described below

commit f1871782cdac733949816c469e68fc9ad5229fbe
Author: Mark Struberg <struberg@apache.org>
AuthorDate: Wed Mar 31 21:40:01 2021 +0200

    fix a test to also work with MSSQL
    
    SQL Server doesn't know BLOB data type, use IMAGE works
---
 .../jdbc/schema/TestSchemaGenerationProperties.java        | 13 +++++++++----
 .../openjpa/persistence/jdbc/schema/create-mssql.sql       | 14 ++++++++++++++
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/schema/TestSchemaGenerationProperties.java
b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/schema/TestSchemaGenerationProperties.java
index b74c4a6..efc9c27 100644
--- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/schema/TestSchemaGenerationProperties.java
+++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/schema/TestSchemaGenerationProperties.java
@@ -32,6 +32,7 @@ import org.apache.openjpa.jdbc.schema.SchemaGroup;
 import org.apache.openjpa.jdbc.schema.SchemaTool;
 import org.apache.openjpa.jdbc.sql.DBDictionary;
 import org.apache.openjpa.jdbc.sql.PostgresDictionary;
+import org.apache.openjpa.jdbc.sql.SQLServerDictionary;
 import org.apache.openjpa.persistence.OpenJPAEntityManager;
 import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
 import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
@@ -173,10 +174,14 @@ public class TestSchemaGenerationProperties extends BaseJDBCTest {
         JDBCConfiguration conf = (JDBCConfiguration) getPM().getConfiguration();
         DBDictionary dict = conf.getDBDictionaryInstance();
 
-        String createSql =
-                dict instanceof PostgresDictionary
-                        ? "org/apache/openjpa/persistence/jdbc/schema/create-postgresql.sql"
-                        : "org/apache/openjpa/persistence/jdbc/schema/create.sql";
+        String createSql;
+        if (dict instanceof PostgresDictionary) {
+            createSql = "org/apache/openjpa/persistence/jdbc/schema/create-postgresql.sql";
+        } else if (dict instanceof SQLServerDictionary) {
+            createSql = "org/apache/openjpa/persistence/jdbc/schema/create-mssql.sql";
+        } else {
+             createSql = "org/apache/openjpa/persistence/jdbc/schema/create.sql";
+        }
 
         Map<String, String> properties = new HashMap<>();
         properties.put("javax.persistence.schema-generation.database.action", "drop-and-create");
diff --git a/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/jdbc/schema/create-mssql.sql
b/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/jdbc/schema/create-mssql.sql
new file mode 100644
index 0000000..1bb2293
--- /dev/null
+++ b/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/jdbc/schema/create-mssql.sql
@@ -0,0 +1,14 @@
+CREATE TABLE AUTOINCPC1 (ID INTEGER NOT NULL, STRNGFLD VARCHAR(50), DTYPE VARCHAR(255), ONEONE_ID
INTEGER, INTFIELD INTEGER, CONSTRAINT SQL150111133630290 PRIMARY KEY (ID));
+CREATE TABLE AUTOINCPC3 (ID BIGINT NOT NULL, STRNGFLD VARCHAR(50), ONEONE_ID BIGINT, CONSTRAINT
SQL150111133630380 PRIMARY KEY (ID));
+CREATE TABLE CONJOINPC4 (ID INTEGER NOT NULL, MANYTOMANY IMAGE, NAME VARCHAR(50), ONETOONE1_ID
INTEGER, CONSTRAINT SQL150111133630400 PRIMARY KEY (ID));
+CREATE TABLE CONJOINPC5 (ID INTEGER NOT NULL, NAME VARCHAR(255), CONSTRAINT SQL150111133630420
PRIMARY KEY (ID));
+CREATE TABLE CUSTMAPPC (ID INTEGER NOT NULL, FEMALE SMALLINT, NAME VARCHAR(50), CONSTRAINT
SQL150111133630430 PRIMARY KEY (ID));
+CREATE TABLE DFGTEST (ID BIGINT NOT NULL, DFGFIELD INTEGER, NONDFGFIELD INTEGER, CONSTRAINT
SQL150111133630450 PRIMARY KEY (ID));
+CREATE TABLE EAGEROUTERJOINPC (ID BIGINT NOT NULL, NAME VARCHAR(255), HELPER IMAGE, CONSTRAINT
SQL150111133630460 PRIMARY KEY (ID));
+CREATE TABLE EAGERPC (ID INTEGER NOT NULL, STRNGFLD VARCHAR(50), EAGER_ID INTEGER, EAGSUB
INTEGER, HELPER_ID INTEGER, RECURSE_ID INTEGER, CONSTRAINT SQL150111133630470 PRIMARY KEY
(ID));
+CREATE TABLE EAGERPCSUB (ID INTEGER NOT NULL, INTFIELD INTEGER, CONSTRAINT SQL150111133630480
PRIMARY KEY (ID));
+CREATE TABLE HELPERPC (ID INTEGER NOT NULL, STRNGFLD VARCHAR(50), EAGER_ID INTEGER, HELPER
IMAGE, CONSTRAINT SQL150111133630500 PRIMARY KEY (ID));
+CREATE TABLE HELPERPC2 (ID INTEGER NOT NULL, STRNGFLD VARCHAR(50), HELPER_ID INTEGER, CONSTRAINT
SQL150111133630510 PRIMARY KEY (ID));
+CREATE TABLE HELPERPC3 (ID INTEGER NOT NULL, STRNGFLD VARCHAR(50), DTYPE VARCHAR(255), INTFIELD
INTEGER, CONSTRAINT SQL150111133630520 PRIMARY KEY (ID));
+CREATE TABLE INVERTA (ID INTEGER NOT NULL, TEST VARCHAR(35), INVERTB_ID INTEGER, CONSTRAINT
SQL150111133630530 PRIMARY KEY (ID));
+CREATE TABLE INVERTB (ID INTEGER NOT NULL, TEST VARCHAR(35), INVERTA_ID INTEGER, CONSTRAINT
SQL150111133630540 PRIMARY KEY (ID));

Mime
View raw message