Skip to content

Commit 8582ae1

Browse files
committed
Remove Deprecated Kotlin code
1 parent 24fef48 commit 8582ae1

File tree

3 files changed

+8
-78
lines changed

3 files changed

+8
-78
lines changed

src/main/kotlin/org/mybatis/dynamic/sql/util/kotlin/KotlinBaseBuilders.kt

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@ import org.mybatis.dynamic.sql.where.AbstractWhereStarter
2525
@DslMarker
2626
annotation class MyBatisDslMarker
2727

28-
@Deprecated("Please use GroupingCriteriaCollector.where")
29-
typealias WhereApplier = KotlinBaseBuilder<*>.() -> Unit
30-
31-
@Deprecated("Please use GroupingCriteriaCollector.where")
32-
fun WhereApplier.andThen(after: WhereApplier): WhereApplier = {
33-
invoke(this)
34-
after(this)
35-
}
36-
3728
@MyBatisDslMarker
3829
@Suppress("TooManyFunctions")
3930
abstract class KotlinBaseBuilder<D : AbstractWhereStarter<*,*>> {
@@ -51,31 +42,6 @@ abstract class KotlinBaseBuilder<D : AbstractWhereStarter<*,*>> {
5142
getDsl().where(criteria)
5243
}
5344

54-
@Deprecated("Please move the \"and\" function into the where lambda. If the where lambda has more than one condition, you may need to surround the existing conditions with \"group\" first.")
55-
fun and(criteria: GroupingCriteriaReceiver): Unit =
56-
GroupingCriteriaCollector().apply(criteria).let {
57-
getDsl().where().and(it.initialCriterion, it.subCriteria)
58-
}
59-
60-
@Deprecated("Please move the \"and\" function into the where lambda. If the where lambda has more than one condition, you may need to surround the existing conditions with \"group\" first.")
61-
fun and(criteria: List<AndOrCriteriaGroup>) {
62-
getDsl().where().and(criteria)
63-
}
64-
65-
@Deprecated("Please move the \"or\" function into the where lambda. If the where lambda has more than one condition, you may need to surround the existing conditions with \"group\" first.")
66-
fun or(criteria: GroupingCriteriaReceiver): Unit =
67-
GroupingCriteriaCollector().apply(criteria).let {
68-
getDsl().where().or(it.initialCriterion, it.subCriteria)
69-
}
70-
71-
@Deprecated("Please move the \"or\" function into the where lambda. If the where lambda has more than one condition, you may need to surround the existing conditions with \"group\" first.")
72-
fun or(criteria: List<AndOrCriteriaGroup>) {
73-
getDsl().where().or(criteria)
74-
}
75-
76-
@Deprecated("Please use GroupingCriteriaCollector.where, then pass it to the \"where\" method")
77-
fun applyWhere(whereApplier: WhereApplier) = whereApplier.invoke(this)
78-
7945
/**
8046
* This function does nothing, but it can be used to make some code snippets more understandable.
8147
*

src/test/kotlin/examples/kotlin/mybatis3/canonical/ReusableWhereTest.kt

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import org.junit.jupiter.api.BeforeAll
2727
import org.junit.jupiter.api.Test
2828
import org.junit.jupiter.api.TestInstance
2929
import org.mybatis.dynamic.sql.util.kotlin.GroupingCriteriaCollector.Companion.where
30-
import org.mybatis.dynamic.sql.util.kotlin.WhereApplier
3130
import org.mybatis.dynamic.sql.util.kotlin.andThen
3231
import org.mybatis.dynamic.sql.util.kotlin.mybatis3.select
3332

@@ -44,19 +43,6 @@ class ReusableWhereTest {
4443
}
4544
}
4645

47-
@Test
48-
fun testCountWithDeprecatedClause() {
49-
sqlSessionFactory.openSession().use { session ->
50-
val mapper = session.getMapper(PersonMapper::class.java)
51-
52-
val rows = mapper.count {
53-
applyWhere(commonWhere)
54-
}
55-
56-
assertThat(rows).isEqualTo(3)
57-
}
58-
}
59-
6046
@Test
6147
fun testDelete() {
6248
sqlSessionFactory.openSession().use { session ->
@@ -98,27 +84,6 @@ class ReusableWhereTest {
9884
}
9985
}
10086

101-
@Test
102-
fun testDeprecatedComposition() {
103-
val composedWhereClause = commonWhere.andThen {
104-
and { birthDate.isNotNull() }
105-
}.andThen {
106-
or { addressId isLessThan 3 }
107-
}
108-
109-
val selectStatement = select(person.allColumns()) {
110-
from(person)
111-
applyWhere(composedWhereClause)
112-
}
113-
114-
assertThat(selectStatement.selectStatement).isEqualTo(
115-
"select * from Person " +
116-
"where id = #{parameters.p1,jdbcType=INTEGER} or occupation is null " +
117-
"and birth_date is not null " +
118-
"or address_id < #{parameters.p2,jdbcType=INTEGER}"
119-
)
120-
}
121-
12287
@Test
12388
fun testComposition() {
12489
val composedWhereClause = commonWhereClause.andThen {
@@ -140,11 +105,6 @@ class ReusableWhereTest {
140105
)
141106
}
142107

143-
private val commonWhere: WhereApplier = {
144-
where { id isEqualTo 1 }
145-
or { occupation.isNull() }
146-
}
147-
148108
private val commonWhereClause = where {
149109
id isEqualTo 1
150110
or { occupation.isNull() }

src/test/kotlin/issues/kotlin/gh430/KNoInitialConditionsTest.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,10 @@ class KNoInitialConditionsTest {
175175

176176
val selectStatement = select(column1, column2) {
177177
from(foo)
178-
where { column1 isLessThan Date() }
179-
or(criteria)
178+
where {
179+
column1 isLessThan Date()
180+
or(criteria)
181+
}
180182
}
181183

182184
val expected = "select column1, column2 from foo where column1 < :p1 " +
@@ -187,7 +189,9 @@ class KNoInitialConditionsTest {
187189
private fun buildSelectStatement(criteria: List<AndOrCriteriaGroup>) =
188190
select(column1, column2) {
189191
from(foo)
190-
where { column1 isLessThan Date() }
191-
and(criteria)
192+
where {
193+
column1 isLessThan Date()
194+
and(criteria)
195+
}
192196
}
193197
}

0 commit comments

Comments
 (0)