Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
274f303b
提交
274f303b
authored
2月 27, 2011
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleanup:
- Increment by something that isn't a number directly didn't work
上级
b5d1d344
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
19 行增加
和
16 行删除
+19
-16
UpdateTest.java
h2/src/test/org/h2/test/jaqu/UpdateTest.java
+9
-0
Db.java
h2/src/tools/org/h2/jaqu/Db.java
+8
-8
IncrementColumn.java
h2/src/tools/org/h2/jaqu/IncrementColumn.java
+2
-8
没有找到文件。
h2/src/test/org/h2/test/jaqu/UpdateTest.java
浏览文件 @
274f303b
...
@@ -144,6 +144,15 @@ public class UpdateTest extends TestBase {
...
@@ -144,6 +144,15 @@ public class UpdateTest extends TestBase {
assertEquals
(
original
.
productName
,
restored
.
productName
);
assertEquals
(
original
.
productName
,
restored
.
productName
);
assertEquals
(
original
.
unitPrice
,
restored
.
unitPrice
);
assertEquals
(
original
.
unitPrice
,
restored
.
unitPrice
);
assertEquals
(
original
.
unitsInStock
,
restored
.
unitsInStock
);
assertEquals
(
original
.
unitsInStock
,
restored
.
unitsInStock
);
double
unitPriceOld
=
db
.
from
(
p
).
where
(
p
.
productId
).
is
(
1
).
selectFirst
().
unitPrice
;
// double the unit price
db
.
from
(
p
).
increment
(
p
.
unitPrice
).
by
(
p
.
unitPrice
)
.
where
(
p
.
productId
).
is
(
1
).
update
();
double
unitPriceNew
=
db
.
from
(
p
).
where
(
p
.
productId
).
is
(
1
).
selectFirst
().
unitPrice
;
assertEquals
(
unitPriceOld
*
2
,
unitPriceNew
);
}
}
}
}
h2/src/tools/org/h2/jaqu/Db.java
浏览文件 @
274f303b
...
@@ -59,7 +59,7 @@ public class Db {
...
@@ -59,7 +59,7 @@ public class Db {
dialect
=
getDialect
(
conn
.
getClass
().
getCanonicalName
());
dialect
=
getDialect
(
conn
.
getClass
().
getCanonicalName
());
}
}
SQLDialect
getDialect
(
String
clazz
)
{
private
SQLDialect
getDialect
(
String
clazz
)
{
int
todo
;
int
todo
;
// TODO add special cases here
// TODO add special cases here
return
new
DefaultSQLDialect
();
return
new
DefaultSQLDialect
();
...
@@ -124,33 +124,32 @@ public class Db {
...
@@ -124,33 +124,32 @@ public class Db {
public
<
T
>
void
insert
(
T
t
)
{
public
<
T
>
void
insert
(
T
t
)
{
Class
<?>
clazz
=
t
.
getClass
();
Class
<?>
clazz
=
t
.
getClass
();
int
upgradeDbSoundsWrongHere
;
define
(
clazz
).
createTableIfRequired
(
this
).
insert
(
this
,
t
,
false
);
upgradeDb
().
define
(
clazz
).
createTableIfRequired
(
this
).
insert
(
this
,
t
,
false
);
}
}
public
<
T
>
long
insertAndGetKey
(
T
t
)
{
public
<
T
>
long
insertAndGetKey
(
T
t
)
{
Class
<?>
clazz
=
t
.
getClass
();
Class
<?>
clazz
=
t
.
getClass
();
return
upgradeDb
().
define
(
clazz
).
createTableIfRequired
(
this
).
insert
(
this
,
t
,
true
);
return
define
(
clazz
).
createTableIfRequired
(
this
).
insert
(
this
,
t
,
true
);
}
}
public
<
T
>
void
merge
(
T
t
)
{
public
<
T
>
void
merge
(
T
t
)
{
Class
<?>
clazz
=
t
.
getClass
();
Class
<?>
clazz
=
t
.
getClass
();
upgradeDb
().
define
(
clazz
).
createTableIfRequired
(
this
).
merge
(
this
,
t
);
define
(
clazz
).
createTableIfRequired
(
this
).
merge
(
this
,
t
);
}
}
public
<
T
>
void
update
(
T
t
)
{
public
<
T
>
void
update
(
T
t
)
{
Class
<?>
clazz
=
t
.
getClass
();
Class
<?>
clazz
=
t
.
getClass
();
upgradeDb
().
define
(
clazz
).
createTableIfRequired
(
this
).
update
(
this
,
t
);
define
(
clazz
).
createTableIfRequired
(
this
).
update
(
this
,
t
);
}
}
public
<
T
>
void
delete
(
T
t
)
{
public
<
T
>
void
delete
(
T
t
)
{
Class
<?>
clazz
=
t
.
getClass
();
Class
<?>
clazz
=
t
.
getClass
();
upgradeDb
().
define
(
clazz
).
createTableIfRequired
(
this
).
delete
(
this
,
t
);
define
(
clazz
).
createTableIfRequired
(
this
).
delete
(
this
,
t
);
}
}
public
<
T
extends
Object
>
Query
<
T
>
from
(
T
alias
)
{
public
<
T
extends
Object
>
Query
<
T
>
from
(
T
alias
)
{
Class
<?>
clazz
=
alias
.
getClass
();
Class
<?>
clazz
=
alias
.
getClass
();
upgradeDb
().
define
(
clazz
).
createTableIfRequired
(
this
);
define
(
clazz
).
createTableIfRequired
(
this
);
return
Query
.
from
(
this
,
alias
);
return
Query
.
from
(
this
,
alias
);
}
}
...
@@ -229,6 +228,7 @@ public class Db {
...
@@ -229,6 +228,7 @@ public class Db {
<
T
>
TableDefinition
<
T
>
define
(
Class
<
T
>
clazz
)
{
<
T
>
TableDefinition
<
T
>
define
(
Class
<
T
>
clazz
)
{
TableDefinition
<
T
>
def
=
getTableDefinition
(
clazz
);
TableDefinition
<
T
>
def
=
getTableDefinition
(
clazz
);
if
(
def
==
null
)
{
if
(
def
==
null
)
{
upgradeDb
();
def
=
new
TableDefinition
<
T
>(
clazz
);
def
=
new
TableDefinition
<
T
>(
clazz
);
def
.
mapFields
();
def
.
mapFields
();
classMap
.
put
(
clazz
,
def
);
classMap
.
put
(
clazz
,
def
);
...
...
h2/src/tools/org/h2/jaqu/IncrementColumn.java
浏览文件 @
274f303b
...
@@ -34,14 +34,8 @@ public class IncrementColumn<T, A> implements Declaration {
...
@@ -34,14 +34,8 @@ public class IncrementColumn<T, A> implements Declaration {
query
.
appendSQL
(
stat
,
x
);
query
.
appendSQL
(
stat
,
x
);
stat
.
appendSQL
(
"=("
);
stat
.
appendSQL
(
"=("
);
query
.
appendSQL
(
stat
,
x
);
query
.
appendSQL
(
stat
,
x
);
int
todoSomethingWrongHere
;
stat
.
appendSQL
(
"+"
);
if
(
y
instanceof
Number
)
{
query
.
appendSQL
(
stat
,
y
);
Number
n
=
(
Number
)
y
;
if
(
n
.
doubleValue
()
>
0
)
{
stat
.
appendSQL
(
"+"
);
}
}
stat
.
appendSQL
(
y
.
toString
());
stat
.
appendSQL
(
")"
);
stat
.
appendSQL
(
")"
);
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论