Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
1c47ba6b
提交
1c47ba6b
authored
8月 09, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add limited support for MONEY and SMALLMONEY data types in compatibility modes
上级
fd53ce0b
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
74 行增加
和
2 行删除
+74
-2
Mode.java
h2/src/main/org/h2/engine/Mode.java
+16
-1
DataType.java
h2/src/main/org/h2/value/DataType.java
+12
-1
TestCompatibility.java
h2/src/test/org/h2/test/db/TestCompatibility.java
+46
-0
没有找到文件。
h2/src/main/org/h2/engine/Mode.java
浏览文件 @
1c47ba6b
...
...
@@ -259,6 +259,16 @@ public class Mode {
// MS SQL Server does not support client info properties. See
// https://msdn.microsoft.com/en-Us/library/dd571296%28v=sql.110%29.aspx
mode
.
supportedClientInfoPropertiesRegEx
=
null
;
DataType
dt
=
DataType
.
createDecimal
(
19
,
19
,
4
,
21
,
false
,
false
);
dt
.
type
=
Value
.
DECIMAL
;
dt
.
sqlType
=
Types
.
NUMERIC
;
dt
.
name
=
"MONEY"
;
mode
.
typeByNameMap
.
put
(
"MONEY"
,
dt
);
dt
=
DataType
.
createDecimal
(
10
,
10
,
4
,
12
,
false
,
false
);
dt
.
type
=
Value
.
DECIMAL
;
dt
.
sqlType
=
Types
.
NUMERIC
;
dt
.
name
=
"MONEY"
;
mode
.
typeByNameMap
.
put
(
"SMALLMONEY"
,
dt
);
add
(
mode
);
mode
=
new
Mode
(
ModeEnum
.
MySQL
);
...
...
@@ -290,7 +300,7 @@ public class Mode {
mode
.
supportedClientInfoPropertiesRegEx
=
Pattern
.
compile
(
".*\\..*"
);
mode
.
prohibitEmptyInPredicate
=
true
;
DataType
dt
=
DataType
.
createDate
(
/* 2001-01-01 23:59:59 */
19
,
19
,
"DATE"
,
false
,
0
,
0
);
dt
=
DataType
.
createDate
(
/* 2001-01-01 23:59:59 */
19
,
19
,
"DATE"
,
false
,
0
,
0
);
dt
.
type
=
Value
.
TIMESTAMP
;
dt
.
sqlType
=
Types
.
TIMESTAMP
;
dt
.
name
=
"DATE"
;
...
...
@@ -318,6 +328,11 @@ public class Mode {
disallowedTypes
.
add
(
"TINYINT"
);
disallowedTypes
.
add
(
"BLOB"
);
mode
.
disallowedTypes
=
disallowedTypes
;
dt
=
DataType
.
createDecimal
(
19
,
19
,
2
,
21
,
false
,
false
);
dt
.
type
=
Value
.
DECIMAL
;
dt
.
sqlType
=
Types
.
NUMERIC
;
dt
.
name
=
"MONEY"
;
mode
.
typeByNameMap
.
put
(
"MONEY"
,
dt
);
add
(
mode
);
mode
=
new
Mode
(
ModeEnum
.
Ignite
);
...
...
h2/src/main/org/h2/value/DataType.java
浏览文件 @
1c47ba6b
...
...
@@ -448,7 +448,18 @@ public class DataType {
}
}
private
static
DataType
createDecimal
(
int
maxPrecision
,
/**
* Create a numeric data type.
*
* @param maxPrecision maximum supported precision
* @param defaultPrecision default precision
* @param defaultScale default scale
* @param defaultDisplaySize default display size
* @param needsPrecisionAndScale where precision and scale are supported
* @param autoInc whether the data type is an auto-increment type
* @return data type
*/
public
static
DataType
createDecimal
(
int
maxPrecision
,
int
defaultPrecision
,
int
defaultScale
,
int
defaultDisplaySize
,
boolean
needsPrecisionAndScale
,
boolean
autoInc
)
{
DataType
dataType
=
new
DataType
();
...
...
h2/src/test/org/h2/test/db/TestCompatibility.java
浏览文件 @
1c47ba6b
...
...
@@ -5,6 +5,7 @@
*/
package
org
.
h2
.
test
.
db
;
import
java.math.BigDecimal
;
import
java.nio.charset.StandardCharsets
;
import
java.sql.Connection
;
import
java.sql.DatabaseMetaData
;
...
...
@@ -276,6 +277,21 @@ public class TestCompatibility extends TestDb {
/* Expected! */
}
}
/* Test MONEY data type */
stat
.
execute
(
"DROP TABLE IF EXISTS TEST"
);
stat
.
execute
(
"CREATE TABLE TEST(M MONEY)"
);
stat
.
execute
(
"INSERT INTO TEST(M) VALUES (-92233720368547758.08)"
);
stat
.
execute
(
"INSERT INTO TEST(M) VALUES (0.11111)"
);
stat
.
execute
(
"INSERT INTO TEST(M) VALUES (92233720368547758.07)"
);
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT M FROM TEST ORDER BY M"
);
assertTrue
(
rs
.
next
());
assertEquals
(
new
BigDecimal
(
"-92233720368547758.08"
),
rs
.
getBigDecimal
(
1
));
assertTrue
(
rs
.
next
());
assertEquals
(
new
BigDecimal
(
"0.11"
),
rs
.
getBigDecimal
(
1
));
assertTrue
(
rs
.
next
());
assertEquals
(
new
BigDecimal
(
"92233720368547758.07"
),
rs
.
getBigDecimal
(
1
));
assertFalse
(
rs
.
next
());
}
private
void
testMySQL
()
throws
SQLException
{
...
...
@@ -496,6 +512,36 @@ public class TestCompatibility extends TestDb {
// UNIQUEIDENTIFIER is MSSQL's equivalent of UUID
stat
.
execute
(
"create table test3 (id UNIQUEIDENTIFIER)"
);
/* Test MONEY data type */
stat
.
execute
(
"DROP TABLE IF EXISTS TEST"
);
stat
.
execute
(
"CREATE TABLE TEST(M MONEY)"
);
stat
.
execute
(
"INSERT INTO TEST(M) VALUES (-922337203685477.5808)"
);
stat
.
execute
(
"INSERT INTO TEST(M) VALUES (0.11111)"
);
stat
.
execute
(
"INSERT INTO TEST(M) VALUES (922337203685477.5807)"
);
rs
=
stat
.
executeQuery
(
"SELECT M FROM TEST ORDER BY M"
);
assertTrue
(
rs
.
next
());
assertEquals
(
new
BigDecimal
(
"-922337203685477.5808"
),
rs
.
getBigDecimal
(
1
));
assertTrue
(
rs
.
next
());
assertEquals
(
new
BigDecimal
(
"0.1111"
),
rs
.
getBigDecimal
(
1
));
assertTrue
(
rs
.
next
());
assertEquals
(
new
BigDecimal
(
"922337203685477.5807"
),
rs
.
getBigDecimal
(
1
));
assertFalse
(
rs
.
next
());
/* Test SMALLMONEY data type */
stat
.
execute
(
"DROP TABLE IF EXISTS TEST"
);
stat
.
execute
(
"CREATE TABLE TEST(M SMALLMONEY)"
);
stat
.
execute
(
"INSERT INTO TEST(M) VALUES (-214748.3648)"
);
stat
.
execute
(
"INSERT INTO TEST(M) VALUES (0.11111)"
);
stat
.
execute
(
"INSERT INTO TEST(M) VALUES (214748.3647)"
);
rs
=
stat
.
executeQuery
(
"SELECT M FROM TEST ORDER BY M"
);
assertTrue
(
rs
.
next
());
assertEquals
(
new
BigDecimal
(
"-214748.3648"
),
rs
.
getBigDecimal
(
1
));
assertTrue
(
rs
.
next
());
assertEquals
(
new
BigDecimal
(
"0.1111"
),
rs
.
getBigDecimal
(
1
));
assertTrue
(
rs
.
next
());
assertEquals
(
new
BigDecimal
(
"214748.3647"
),
rs
.
getBigDecimal
(
1
));
assertFalse
(
rs
.
next
());
}
private
void
testDB2
()
throws
SQLException
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论