From bbb185b44ebc93e21038e50597e29fe1fc6b7f09 Mon Sep 17 00:00:00 2001 From: Potmot <377029227@qq.com> Date: Sun, 17 Nov 2024 21:52:45 +0800 Subject: [PATCH 1/2] Add KConfigurableRootQuery exists function --- .../jimmer/sql/kt/ast/query/KConfigurableRootQuery.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/project/jimmer-sql-kotlin/src/main/kotlin/org/babyfish/jimmer/sql/kt/ast/query/KConfigurableRootQuery.kt b/project/jimmer-sql-kotlin/src/main/kotlin/org/babyfish/jimmer/sql/kt/ast/query/KConfigurableRootQuery.kt index abf24b7361..48f8f7e851 100644 --- a/project/jimmer-sql-kotlin/src/main/kotlin/org/babyfish/jimmer/sql/kt/ast/query/KConfigurableRootQuery.kt +++ b/project/jimmer-sql-kotlin/src/main/kotlin/org/babyfish/jimmer/sql/kt/ast/query/KConfigurableRootQuery.kt @@ -6,6 +6,7 @@ import org.babyfish.jimmer.lang.NewChain import org.babyfish.jimmer.sql.ast.query.PageFactory import org.babyfish.jimmer.sql.kt.ast.expression.rowCount import java.sql.Connection +import org.babyfish.jimmer.sql.kt.ast.expression.constant interface KConfigurableRootQuery : KTypedRootQuery { @@ -26,6 +27,11 @@ interface KConfigurableRootQuery : KTypedRootQuery { .withoutSortingAndPaging() .execute(con)[0] + fun exists(con: Connection? = null): Boolean = + limit(1) + .reselect { select(constant(1)) } + .execute(con).isEmpty() + fun fetchPage( pageIndex: Int, pageSize: Int, From bea56d9b2bb8ed3181647437ff5d6e6193a24965 Mon Sep 17 00:00:00 2001 From: Potmot <377029227@qq.com> Date: Sun, 17 Nov 2024 23:25:50 +0800 Subject: [PATCH 2/2] Fix KConfigurableRootQuery.exists isEmpty -> isNotEmpty --- .../babyfish/jimmer/sql/kt/ast/query/KConfigurableRootQuery.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/jimmer-sql-kotlin/src/main/kotlin/org/babyfish/jimmer/sql/kt/ast/query/KConfigurableRootQuery.kt b/project/jimmer-sql-kotlin/src/main/kotlin/org/babyfish/jimmer/sql/kt/ast/query/KConfigurableRootQuery.kt index 48f8f7e851..0150bdacc7 100644 --- a/project/jimmer-sql-kotlin/src/main/kotlin/org/babyfish/jimmer/sql/kt/ast/query/KConfigurableRootQuery.kt +++ b/project/jimmer-sql-kotlin/src/main/kotlin/org/babyfish/jimmer/sql/kt/ast/query/KConfigurableRootQuery.kt @@ -30,7 +30,7 @@ interface KConfigurableRootQuery : KTypedRootQuery { fun exists(con: Connection? = null): Boolean = limit(1) .reselect { select(constant(1)) } - .execute(con).isEmpty() + .execute(con).isNotEmpty() fun fetchPage( pageIndex: Int,