mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix bug
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package cn.hutool.db.dialect;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.db.Entity;
|
||||
import cn.hutool.db.Page;
|
||||
import cn.hutool.db.sql.Order;
|
||||
@@ -134,8 +133,7 @@ public interface Dialect extends Serializable {
|
||||
* @throws SQLException SQL执行异常
|
||||
*/
|
||||
default PreparedStatement psForCount(Connection conn, Query query) throws SQLException {
|
||||
query.setFields(ListUtil.toList("count(1)"));
|
||||
return psForFind(conn, query);
|
||||
return psForCount(conn, SqlBuilder.create().query(query));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -70,6 +70,12 @@ public class DbTest {
|
||||
Assert.assertEquals(4, count);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void countByQueryTest() throws SQLException {
|
||||
final long count = Db.use().count(Entity.create("user"));
|
||||
Assert.assertEquals(4, count);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void countTest2() throws SQLException {
|
||||
final long count = Db.use().count("select * from user order by name DESC");
|
||||
|
Reference in New Issue
Block a user