mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-12-06 17:18:54 +08:00
add test
This commit is contained in:
parent
ce3d69dd35
commit
0cbc36e225
@ -1,12 +1,16 @@
|
||||
package cn.hutool.db;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.db.sql.NamedSql;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* PostgreSQL 单元测试
|
||||
@ -46,4 +50,14 @@ public class PostgreTest {
|
||||
Entity et=db.get(Entity.create("ctest").set("id", 1));
|
||||
assertEquals("new111",et.getStr("t1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
void namedSqlWithInTest() throws SQLException {
|
||||
final HashMap<String, Object> paramMap = MapUtil.of("number", new int[]{1, 2, 3});
|
||||
NamedSql namedSql = new NamedSql("select case when 2 = any(ARRAY[:number]) and 1 in (1) then 1 else 0 end", paramMap);
|
||||
final Db db = Db.use("postgre");
|
||||
final List<Entity> query = db.query(namedSql.getSql(), namedSql.getParams());
|
||||
Console.log(query);
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ pass = 123456
|
||||
remarks = true
|
||||
|
||||
[postgre]
|
||||
url = jdbc:postgresql://looly.centos:5432/test_hutool
|
||||
url = jdbc:postgresql://localhost:5432/test_hutool
|
||||
user = postgres
|
||||
pass = 123456
|
||||
remarks = true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user