mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1972 - Change BigDecimal to map by default DB type DECIMAL(16,3) rather than DECIMAL(38)
This commit is contained in:
@@ -116,7 +116,7 @@ public class DbPlatformTypeMapping {
|
||||
|
||||
} else {
|
||||
put(DbType.VARCHAR, new DbPlatformType("varchar", 255));
|
||||
put(DbType.DECIMAL, new DbPlatformType("decimal", 38));
|
||||
put(DbType.DECIMAL, new DbPlatformType("decimal", 16, 3));
|
||||
put(DbType.VARBINARY, new DbPlatformType("varbinary", 255));
|
||||
put(DbType.BINARY, new DbPlatformType("binary", 255));
|
||||
put(DbType.CHAR, new DbPlatformType("char", 1));
|
||||
|
||||
@@ -32,7 +32,7 @@ public class ClickHousePlatform extends DatabasePlatform {
|
||||
dbTypeMap.put(DbType.SMALLINT, new DbPlatformType("UInt16", false));
|
||||
dbTypeMap.put(DbType.INTEGER, new DbPlatformType("UInt32", false));
|
||||
dbTypeMap.put(DbType.BIGINT, new DbPlatformType("UInt64", false));
|
||||
dbTypeMap.put(DbType.DECIMAL, new DbPlatformType("Decimal", 16,4));
|
||||
dbTypeMap.put(DbType.DECIMAL, new DbPlatformType("Decimal", 16, 3));
|
||||
dbTypeMap.put(DbType.DOUBLE, new DbPlatformType("Float64", false));
|
||||
|
||||
dbTypeMap.put(DbType.DATE, new DbPlatformType("Date", false));
|
||||
|
||||
@@ -42,8 +42,7 @@ public class DB2Platform extends DatabasePlatform {
|
||||
dbTypeMap.put(DbType.INTEGER, new DbPlatformType("integer", false));
|
||||
dbTypeMap.put(DbType.BIGINT, new DbPlatformType("bigint", false));
|
||||
dbTypeMap.put(DbType.REAL, new DbPlatformType("real"));
|
||||
dbTypeMap.put(DbType.DECIMAL, new DbPlatformType("decimal", 15));
|
||||
|
||||
dbTypeMap.put(DbType.DECIMAL, new DbPlatformType("decimal", 16, 3));
|
||||
persistBatchOnCascade = PersistBatch.NONE;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,8 +62,7 @@ public class OraclePlatform extends DatabasePlatform {
|
||||
dbTypeMap.put(DbType.DOUBLE, new DbPlatformType("number", 19, 4));
|
||||
dbTypeMap.put(DbType.SMALLINT, new DbPlatformType("number", 5));
|
||||
dbTypeMap.put(DbType.TINYINT, new DbPlatformType("number", 3));
|
||||
dbTypeMap.put(DbType.DECIMAL, new DbPlatformType("number", 38));
|
||||
|
||||
dbTypeMap.put(DbType.DECIMAL, new DbPlatformType("number", 16, 3));
|
||||
dbTypeMap.put(DbType.VARCHAR, new DbPlatformType("varchar2", 255));
|
||||
|
||||
dbTypeMap.put(DbType.LONGVARBINARY, new DbPlatformType("blob"));
|
||||
|
||||
@@ -70,7 +70,6 @@ public class PostgresPlatform extends DatabasePlatform {
|
||||
dbTypeMap.put(DbType.INTEGER, new DbPlatformType("integer", false));
|
||||
dbTypeMap.put(DbType.DOUBLE, new DbPlatformType("float"));
|
||||
dbTypeMap.put(DbType.TINYINT, new DbPlatformType("smallint"));
|
||||
dbTypeMap.put(DbType.DECIMAL, new DbPlatformType("decimal", 38));
|
||||
dbTypeMap.put(DbType.TIMESTAMP, new DbPlatformType("timestamptz"));
|
||||
|
||||
dbTypeMap.put(DbType.BINARY, dbBytea);
|
||||
|
||||
@@ -32,8 +32,7 @@ public class SqlAnywherePlatform extends DatabasePlatform {
|
||||
dbTypeMap.put(DbType.REAL, new DbPlatformType("float(16)"));
|
||||
dbTypeMap.put(DbType.DOUBLE, new DbPlatformType("float(32)"));
|
||||
dbTypeMap.put(DbType.TINYINT, new DbPlatformType("smallint"));
|
||||
dbTypeMap.put(DbType.DECIMAL, new DbPlatformType("numeric", 28));
|
||||
|
||||
dbTypeMap.put(DbType.DECIMAL, new DbPlatformType("numeric", 16, 3));
|
||||
dbTypeMap.put(DbType.BLOB, new DbPlatformType("binary(4500)"));
|
||||
dbTypeMap.put(DbType.CLOB, new DbPlatformType("long varchar"));
|
||||
dbTypeMap.put(DbType.LONGVARBINARY, new DbPlatformType("long binary"));
|
||||
|
||||
@@ -62,8 +62,7 @@ abstract class SqlServerBasePlatform extends DatabasePlatform {
|
||||
dbTypeMap.put(DbType.REAL, new DbPlatformType("float(16)"));
|
||||
dbTypeMap.put(DbType.DOUBLE, new DbPlatformType("float(32)"));
|
||||
dbTypeMap.put(DbType.TINYINT, new DbPlatformType("smallint"));
|
||||
dbTypeMap.put(DbType.DECIMAL, new DbPlatformType("numeric", 28));
|
||||
|
||||
dbTypeMap.put(DbType.DECIMAL, new DbPlatformType("numeric", 16, 3));
|
||||
dbTypeMap.put(DbType.DATE, new DbPlatformType("date"));
|
||||
dbTypeMap.put(DbType.TIME, new DbPlatformType("time"));
|
||||
dbTypeMap.put(DbType.TIMESTAMP, new DbPlatformType("datetime2"));
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ public class PlatformTypeConverter {
|
||||
} else {
|
||||
// scale - varchar(10)
|
||||
int scale = Integer.parseInt(columnDefinition.substring(open + 1, close));
|
||||
return dbType.renderType(scale, 0) + suffix;
|
||||
return dbType.renderType(scale, -1) + suffix;
|
||||
}
|
||||
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
||||
@@ -49,7 +49,7 @@ public class DatabasePlatformTest {
|
||||
public void defaultTypesForDecimalAndVarchar() {
|
||||
|
||||
DatabasePlatform dbPlatform = new DatabasePlatform();
|
||||
assertEquals(defaultDecimalDefn(dbPlatform), "decimal(38)");
|
||||
assertEquals(defaultDecimalDefn(dbPlatform), "decimal(16,3)");
|
||||
assertEquals(defaultDefn(DbType.VARCHAR, dbPlatform), "varchar(255)");
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ public class H2PlatformTest {
|
||||
assertThat(ddl.convert("varchar(20)")).isEqualTo("varchar(20)");
|
||||
assertThat(ddl.convert("decimal(10)")).isEqualTo("decimal(10)");
|
||||
assertThat(ddl.convert("decimal(8,4)")).isEqualTo("decimal(8,4)");
|
||||
assertThat(ddl.convert("decimal")).isEqualTo("decimal(16,3)");
|
||||
assertThat(ddl.convert("boolean")).isEqualTo("boolean");
|
||||
assertThat(ddl.convert("bit")).isEqualTo("bit");
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public class HanaPlatformTest {
|
||||
assertThat(ddl.convert("varchar(20)")).isEqualTo("nvarchar(20)");
|
||||
assertThat(ddl.convert("decimal(10)")).isEqualTo("decimal(10)");
|
||||
assertThat(ddl.convert("decimal(8,4)")).isEqualTo("decimal(8,4)");
|
||||
assertThat(ddl.convert("decimal")).isEqualTo("decimal(16,3)");
|
||||
assertThat(ddl.convert("boolean")).isEqualTo("boolean");
|
||||
assertThat(ddl.convert("bit")).isEqualTo("smallint");
|
||||
assertThat(ddl.convert("tinyint")).isEqualTo("smallint");
|
||||
|
||||
@@ -21,6 +21,7 @@ public class MySqlPlatformTest {
|
||||
assertThat(ddl.convert("varchar(20)")).isEqualTo("varchar(20)");
|
||||
assertThat(ddl.convert("boolean")).isEqualTo("tinyint(1)");
|
||||
assertThat(ddl.convert("bit")).isEqualTo("tinyint(1)");
|
||||
assertThat(ddl.convert("decimal")).isEqualTo("decimal(16,3)");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -26,6 +26,7 @@ public class OraclePlatformTest {
|
||||
assertThat(ddl.convert("varchar(20)")).isEqualTo("varchar2(20)");
|
||||
assertThat(ddl.convert("decimal(10)")).isEqualTo("number(10)");
|
||||
assertThat(ddl.convert("decimal(8,4)")).isEqualTo("number(8,4)");
|
||||
assertThat(ddl.convert("decimal")).isEqualTo("number(16,3)");
|
||||
assertThat(ddl.convert("boolean")).isEqualTo("number(1)");
|
||||
assertThat(ddl.convert("bit")).isEqualTo("bit");
|
||||
assertThat(ddl.convert("tinyint")).isEqualTo("number(3)");
|
||||
|
||||
@@ -26,11 +26,11 @@ public class PostgresPlatformTest {
|
||||
assertThat(ddl.convert("tinyint")).isEqualTo("smallint");
|
||||
assertThat(ddl.convert("double")).isEqualTo("float");
|
||||
assertThat(ddl.convert("varchar(20)")).isEqualTo("varchar(20)");
|
||||
assertThat(ddl.convert("decimal")).isEqualTo("decimal(16,3)");
|
||||
assertThat(ddl.convert("decimal(10)")).isEqualTo("decimal(10)");
|
||||
assertThat(ddl.convert("decimal(8,4)")).isEqualTo("decimal(8,4)");
|
||||
assertThat(ddl.convert("boolean")).isEqualTo("boolean");
|
||||
assertThat(ddl.convert("bit")).isEqualTo("bit");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -26,6 +26,7 @@ public class SqlserverPlatformTest {
|
||||
assertThat(ddl.convert("varchar(20)")).isEqualTo("nvarchar(20)");
|
||||
assertThat(ddl.convert("decimal(10)")).isEqualTo("numeric(10)");
|
||||
assertThat(ddl.convert("decimal(8,4)")).isEqualTo("numeric(8,4)");
|
||||
assertThat(ddl.convert("decimal")).isEqualTo("numeric(16,3)");
|
||||
assertThat(ddl.convert("boolean")).isEqualTo("bit");
|
||||
assertThat(ddl.convert("bit")).isEqualTo("bit");
|
||||
assertThat(ddl.convert("tinyint")).isEqualTo("smallint");
|
||||
|
||||
Reference in New Issue
Block a user