Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
621bfd06
Unverified
提交
621bfd06
authored
2月 14, 2018
作者:
Noel Grandin
提交者:
GitHub
2月 14, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #877 from katzyn/datetime
Reimplement TO_CHAR without a Calendar and fix 12 AM / 12 PM in it
上级
22ed525f
6d59f0ab
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
108 行增加
和
77 行删除
+108
-77
Function.java
h2/src/main/org/h2/expression/Function.java
+2
-1
ToChar.java
h2/src/main/org/h2/util/ToChar.java
+95
-69
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+10
-7
TestClearReferences.java
h2/src/test/org/h2/test/unit/TestClearReferences.java
+1
-0
没有找到文件。
h2/src/main/org/h2/expression/Function.java
浏览文件 @
621bfd06
...
...
@@ -1449,7 +1449,8 @@ public class Function extends Expression implements FunctionCall {
case
Value
.
TIME
:
case
Value
.
DATE
:
case
Value
.
TIMESTAMP
:
result
=
ValueString
.
get
(
ToChar
.
toChar
(
v0
.
getTimestamp
(),
case
Value
.
TIMESTAMP_TZ
:
result
=
ValueString
.
get
(
ToChar
.
toCharDateTime
(
v0
,
v1
==
null
?
null
:
v1
.
getString
(),
v2
==
null
?
null
:
v2
.
getString
()),
database
.
getMode
().
treatEmptyStringsAsNull
);
...
...
h2/src/main/org/h2/util/ToChar.java
浏览文件 @
621bfd06
差异被折叠。
点击展开。
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
621bfd06
...
...
@@ -1453,7 +1453,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
assertResult
(
"-100-01-15 14:04:02.12"
,
stat
,
"SELECT X FROM U"
);
String
expected
=
String
.
format
(
"%tb"
,
timestamp1979
).
toUpperCase
();
expected
=
stripTrailingPeriod
(
expected
);
assertResult
(
"12-"
+
expected
+
"-79 08.12.34.560000 AM"
,
stat
,
assertResult
(
"12-"
+
expected
+
"-79 08.12.34.560000
000
AM"
,
stat
,
"SELECT TO_CHAR(X) FROM T"
);
assertResult
(
"- / , . ; : text - /"
,
stat
,
"SELECT TO_CHAR(X, '- / , . ; : \"text\" - /') FROM T"
);
...
...
@@ -1492,6 +1492,8 @@ public class TestFunctions extends TestBase implements AggregateFunction {
assertResult
(
"08:12 AM"
,
stat
,
"SELECT TO_CHAR(X, 'HH:MI PM') FROM T"
);
assertResult
(
"02:04 PM"
,
stat
,
"SELECT TO_CHAR(X, 'HH:MI PM') FROM U"
);
assertResult
(
"08:12 A.M."
,
stat
,
"SELECT TO_CHAR(X, 'HH:MI P.M.') FROM T"
);
assertResult
(
"12 PM"
,
stat
,
"SELECT TO_CHAR(TIME '12:00:00', 'HH AM')"
);
assertResult
(
"12 AM"
,
stat
,
"SELECT TO_CHAR(TIME '00:00:00', 'HH AM')"
);
assertResult
(
"A.M."
,
stat
,
"SELECT TO_CHAR(X, 'P.M.') FROM T"
);
assertResult
(
"a.m."
,
stat
,
"SELECT TO_CHAR(X, 'p.M.') FROM T"
);
assertResult
(
"a.m."
,
stat
,
"SELECT TO_CHAR(X, 'p.m.') FROM T"
);
...
...
@@ -1532,7 +1534,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
assertResult
(
Capitalization
.
CAPITALIZE
.
apply
(
expected
),
stat
,
"SELECT TO_CHAR(X, 'Dy') FROM T"
);
assertResult
(
expected
.
toLowerCase
(),
stat
,
"SELECT TO_CHAR(X, 'dy') FROM T"
);
assertResult
(
expected
.
toLowerCase
(),
stat
,
"SELECT TO_CHAR(X, 'dY') FROM T"
);
assertResult
(
"08:12:34.560000"
,
stat
,
assertResult
(
"08:12:34.560000
000
"
,
stat
,
"SELECT TO_CHAR(X, 'HH:MI:SS.FF') FROM T"
);
assertResult
(
"08:12:34.5"
,
stat
,
"SELECT TO_CHAR(X, 'HH:MI:SS.FF1') FROM T"
);
...
...
@@ -1552,10 +1554,10 @@ public class TestFunctions extends TestBase implements AggregateFunction {
"SELECT TO_CHAR(X, 'HH:MI:SS.FF8') FROM T"
);
assertResult
(
"08:12:34.560000000"
,
stat
,
"SELECT TO_CHAR(X, 'HH:MI:SS.FF9') FROM T"
);
assertResult
(
"0
8:12:34.560000000
"
,
stat
,
"SELECT TO_CHAR(
X, 'HH:MI:SS.ff9
') FROM T"
);
assertResult
(
"0
8:12:34.56000000
0"
,
stat
,
"SELECT TO_CHAR(
X, 'HH:MI:SS.fF9
') FROM T"
);
assertResult
(
"0
12345678
"
,
stat
,
"SELECT TO_CHAR(
TIME '0:00:00.012345678', 'FF
') FROM T"
);
assertResult
(
"00"
,
stat
,
"SELECT TO_CHAR(
TIME '0:00:00.000', 'FF2
') FROM T"
);
assertResult
(
"08:12"
,
stat
,
"SELECT TO_CHAR(X, 'HH:MI') FROM T"
);
assertResult
(
"08:12"
,
stat
,
"SELECT TO_CHAR(X, 'HH12:MI') FROM T"
);
assertResult
(
"08:12"
,
stat
,
"SELECT TO_CHAR(X, 'HH24:MI') FROM T"
);
...
...
@@ -1903,7 +1905,8 @@ public class TestFunctions extends TestBase implements AggregateFunction {
final
String
twoDecimals
=
"0"
+
decimalSeparator
+
"00"
;
assertResult
(
oneDecimal
,
stat
,
"select to_char(0, 'FM0D099') from dual;"
);
assertResult
(
twoDecimals
,
stat
,
"select to_char(0., 'FM0D009') from dual;"
);
assertResult
(
"0.000000000"
,
stat
,
"select to_char(0.000000000, 'FM0D999999999') from dual;"
);
assertResult
(
"0"
+
decimalSeparator
+
"000000000"
,
stat
,
"select to_char(0.000000000, 'FM0D999999999') from dual;"
);
assertResult
(
"0"
+
decimalSeparator
,
stat
,
"select to_char(0, 'FM0D9') from dual;"
);
assertResult
(
oneDecimal
,
stat
,
"select to_char(0.0, 'FM0D099') from dual;"
);
assertResult
(
twoDecimals
,
stat
,
"select to_char(0.00, 'FM0D009') from dual;"
);
...
...
h2/src/test/org/h2/test/unit/TestClearReferences.java
浏览文件 @
621bfd06
...
...
@@ -43,6 +43,7 @@ public class TestClearReferences extends TestBase {
"org.h2.util.JdbcUtils.allowedClassNamePrefixes"
,
"org.h2.util.JdbcUtils.userClassFactories"
,
"org.h2.util.Task.counter"
,
"org.h2.util.ToChar.NAMES"
,
"org.h2.value.CompareMode.lastUsed"
,
"org.h2.value.Value.softCache"
,
};
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论