Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
ae6da320
提交
ae6da320
authored
7 年前
作者:
Noel Grandin
提交者:
GitHub
7 年前
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #523 from stumc/Issue#458
Issue#458 TIMESTAMPDIFF YEAR fix
上级
8b018f2b
d284f797
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
25 行增加
和
6 行删除
+25
-6
Function.java
h2/src/main/org/h2/expression/Function.java
+3
-3
TestScriptSimple.java
h2/src/test/org/h2/test/db/TestScriptSimple.java
+2
-0
testScript.sql
h2/src/test/org/h2/test/testScript.sql
+14
-0
ImmutableArray.java
h2/src/tools/org/h2/dev/util/ImmutableArray.java
+2
-1
ImmutableArray2.java
h2/src/tools/org/h2/dev/util/ImmutableArray2.java
+2
-1
ImmutableArray3.java
h2/src/tools/org/h2/dev/util/ImmutableArray3.java
+2
-1
没有找到文件。
h2/src/main/org/h2/expression/Function.java
浏览文件 @
ae6da320
...
...
@@ -1887,11 +1887,11 @@ public class Function extends Expression implements FunctionCall {
calendar
.
setTimeInMillis
(
t2
);
int
year2
=
calendar
.
get
(
Calendar
.
YEAR
);
int
month2
=
calendar
.
get
(
Calendar
.
MONTH
);
int
r
esult
=
year2
-
year1
;
int
yearR
esult
=
year2
-
year1
;
if
(
field
==
Calendar
.
MONTH
)
{
return
12
*
r
esult
+
(
month2
-
month1
);
return
12
*
yearR
esult
+
(
month2
-
month1
);
}
else
if
(
field
==
Calendar
.
YEAR
)
{
return
result
;
return
(
12
*
yearResult
+
(
month2
-
month1
))/
12
;
}
else
{
throw
DbException
.
getUnsupportedException
(
"DATEDIFF "
+
part
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/db/TestScriptSimple.java
浏览文件 @
ae6da320
...
...
@@ -11,6 +11,7 @@ import java.io.LineNumberReader;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
org.h2.test.TestBase
;
import
org.h2.util.ScriptReader
;
...
...
@@ -72,6 +73,7 @@ public class TestScriptSimple extends TestBase {
}
conn
.
close
();
deleteDb
(
"scriptSimple"
);
}
private
void
reconnect
()
throws
SQLException
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/testScript.sql
浏览文件 @
ae6da320
...
...
@@ -9909,15 +9909,29 @@ select dateadd('year', -1, timestamp '2000-02-29 10:20:30.012345678') d1 from te
>
1999
-
02
-
28
10
:
20
:
30
.
012345678
>
rows
:
1
-- Only 2 months difference, not a whole year
select
datediff
(
'yy'
,
timestamp
'2003-12-01 10:20:30.0'
,
timestamp
'2004-01-01 10:00:00.0'
)
d1
from
test
;
>
D1
>
--
>
0
>
rows
:
1
select
datediff
(
'yy'
,
timestamp
'2003-12-01 10:20:30.0'
,
timestamp
'2004-12-01 10:20:30.0'
)
d1
from
test
;
>
D1
>
--
>
1
>
rows
:
1
-- Only 2 months difference, not a whole year
select
datediff
(
'year'
,
timestamp
'2003-12-01 10:20:30.0'
,
timestamp
'2004-01-01 10:00:00.0'
)
d1
from
test
;
>
D1
>
--
>
0
>
rows
:
1
select
datediff
(
'year'
,
timestamp
'2003-12-01 10:20:30.0'
,
timestamp
'2004-12-01 10:20:30.0'
)
d1
from
test
;
>
D1
>
--
>
1
>
rows
:
1
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/dev/util/ImmutableArray.java
浏览文件 @
ae6da320
...
...
@@ -111,7 +111,8 @@ public final class ImmutableArray<K> implements Iterable<K> {
* @param array the data
* @return the new immutable array
*/
public
static
<
K
>
ImmutableArray
<
K
>
create
(
K
...
array
)
{
@SafeVarargs
public
static
<
K
>
ImmutableArray
<
K
>
create
(
K
...
array
)
{
return
new
ImmutableArray
<
K
>(
array
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/dev/util/ImmutableArray2.java
浏览文件 @
ae6da320
...
...
@@ -151,7 +151,8 @@ public final class ImmutableArray2<K> implements Iterable<K> {
* @param array the data
* @return the new immutable array
*/
public
static
<
K
>
ImmutableArray2
<
K
>
create
(
K
...
array
)
{
@SafeVarargs
public
static
<
K
>
ImmutableArray2
<
K
>
create
(
K
...
array
)
{
return
new
ImmutableArray2
<
K
>(
array
,
array
.
length
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/dev/util/ImmutableArray3.java
浏览文件 @
ae6da320
...
...
@@ -84,7 +84,8 @@ public abstract class ImmutableArray3<K> implements Iterable<K> {
* @param array the data
* @return the new immutable array
*/
public
static
<
K
>
ImmutableArray3
<
K
>
create
(
K
...
array
)
{
@SafeVarargs
public
static
<
K
>
ImmutableArray3
<
K
>
create
(
K
...
array
)
{
return
new
Plain
<
K
>(
array
);
}
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论