diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeMapping.java b/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeMapping.java index 3cb362ecc..6a7e77683 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeMapping.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeMapping.java @@ -59,16 +59,17 @@ public class DbPlatformTypeMapping { put(DbType.TIMESTAMP); put(DbType.LONGVARBINARY); put(DbType.LONGVARCHAR); - - put(DbType.VARBINARY, new DbPlatformType("varbinary", 255)); - put(DbType.BINARY, new DbPlatformType("binary", 255)); - put(DbType.REAL, new DbPlatformType("float")); // most commonly read maps to db float - put(DbType.DECIMAL, new DbPlatformType("decimal", 38)); - put(DbType.VARCHAR, new DbPlatformType("varchar", 255)); - put(DbType.CHAR, new DbPlatformType("char", 1)); + // most commonly real maps to db float + put(DbType.REAL, new DbPlatformType("float")); if (logicalTypes) { // keep it logical for 2 layer DDL generation + put(DbType.VARCHAR, new DbPlatformType("varchar")); + put(DbType.DECIMAL, new DbPlatformType("decimal")); + put(DbType.VARBINARY, new DbPlatformType("varbinary")); + put(DbType.BINARY, new DbPlatformType("binary")); + put(DbType.CHAR, new DbPlatformType("char")); + put(DbType.HSTORE, new DbPlatformType("hstore", false)); put(DbType.JSON, new DbPlatformType("json", false)); put(DbType.JSONB, new DbPlatformType("jsonb", false)); @@ -78,6 +79,12 @@ public class DbPlatformTypeMapping { put(DbType.UUID, UUID_NATIVE); } else { + put(DbType.VARCHAR, new DbPlatformType("varchar", 255)); + put(DbType.DECIMAL, new DbPlatformType("decimal", 38)); + put(DbType.VARBINARY, new DbPlatformType("varbinary", 255)); + put(DbType.BINARY, new DbPlatformType("binary", 255)); + put(DbType.CHAR, new DbPlatformType("char", 1)); + put(DbType.JSON, JSON_CLOB_PLACEHOLDER); // Postgres maps this to JSON put(DbType.JSONB, JSON_CLOB_PLACEHOLDER); // Postgres maps this to JSONB put(DbType.JSONCLOB, JSON_CLOB_PLACEHOLDER); diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeParser.java b/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeParser.java index 14a1c60db..ec0d440b5 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeParser.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeParser.java @@ -14,11 +14,11 @@ class DbPlatformTypeParser { int openPos = columnDefinition.indexOf('('); if (openPos == -1) { - return new DbPlatformType(columnDefinition); + return new DbPlatformType(columnDefinition, false); } int closePos = columnDefinition.indexOf(')', openPos); if (closePos == -1) { - return new DbPlatformType(columnDefinition); + return new DbPlatformType(columnDefinition, false); } try { int commaPos = columnDefinition.indexOf(',', openPos); @@ -34,7 +34,7 @@ class DbPlatformTypeParser { return new DbPlatformType(type, scale); } } catch (RuntimeException e) { - return new DbPlatformType(columnDefinition); + return new DbPlatformType(columnDefinition, false); } } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PlatformDdl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PlatformDdl.java index e0e8b025c..460300bf6 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PlatformDdl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PlatformDdl.java @@ -110,7 +110,6 @@ public class PlatformDdl { * Set configuration options. */ public void configure(ServerConfig serverConfig) { - platform.configure(serverConfig); historyDdl.configure(serverConfig, this); naming = serverConfig.getConstraintNaming(); } diff --git a/src/test/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeParserTest.java b/src/test/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeParserTest.java index bc2990515..45e5ceb18 100644 --- a/src/test/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeParserTest.java +++ b/src/test/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeParserTest.java @@ -16,7 +16,7 @@ public class DbPlatformTypeParserTest { assertEquals(type.getDefaultScale(), 0); assertEquals(type.renderType(0, 0), "text"); - assertEquals(type.renderType(40, 0), "text(40)"); + assertEquals(type.renderType(40, 0), "text"); } @Test