达梦数据库方言的upsert完成测试

This commit is contained in:
吴博 2024-02-22 10:32:52 +08:00
parent d9cda15078
commit 3c5f905195
4 changed files with 51 additions and 1 deletions

View File

@ -178,5 +178,11 @@
<version>0.5.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.dameng</groupId>
<artifactId>DmJdbcDriver18</artifactId>
<version>8.1.2.141</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -17,7 +17,7 @@ import java.util.List;
/**
* 达梦数据库方言
*
* @author wubo
* @author wb04307201
*/
public class DmDialect extends AnsiSqlDialect {
private static final long serialVersionUID = 3415348435502927423L;

View File

@ -0,0 +1,36 @@
package cn.hutool.db;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import java.sql.SQLException;
/**
* 达梦数据库单元测试
*
* @author wb04307201
*/
public class DmTest {
private static final String DS_GROUP_NAME = "dm";
@BeforeClass
public static void init() throws SQLException {
Db db = Db.use(DS_GROUP_NAME);
db.execute("CREATE TABLE test(a INTEGER, b INTEGER)");
db.insert(Entity.create("test").set("a", 1).set("b", 11));
db.insert(Entity.create("test").set("a", 2).set("b", 21));
db.insert(Entity.create("test").set("a", 3).set("b", 31));
db.insert(Entity.create("test").set("a", 4).set("b", 41));
}
@Test
public void upsertTest() throws SQLException {
Db db = Db.use(DS_GROUP_NAME);
db.upsert(Entity.create("test").set("a", 1).set("b", 111), "a");
Entity a1 = db.get("test", "a", 1);
Assert.assertEquals(Long.valueOf(111), a1.getLong("b"));
}
}

View File

@ -69,3 +69,11 @@ url = jdbc:sqlserver://looly.database.chinacloudapi.cn:1433;database=test;encryp
user = looly@looly
pass = 123
remarks = true
# 测试用dm数据库
[dm]
url = jdbc:dm://127.0.0.1:30236/schema=dm8_test
user = SYSDBA
pass = SYSDBA001
remarks = true