Skip to content

Commit 055d021

Browse files
committed
Restore old pattern for running mappers
1 parent cbeff50 commit 055d021

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/main/kotlin/org/mybatis/dynamic/sql/util/kotlin/mybatis3/MapperSupportFunctions.kt

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,38 +41,38 @@ fun count(
4141
table: SqlTable,
4242
completer: CountCompleter
4343
): Long =
44-
mapper(count(column) {
44+
count(column) {
4545
from(table)
4646
run(completer)
47-
})
47+
}.run(mapper)
4848

4949
fun countDistinct(
5050
mapper: (SelectStatementProvider) -> Long,
5151
column: BasicColumn,
5252
table: SqlTable,
5353
completer: CountCompleter
5454
): Long =
55-
mapper(countDistinct(column) {
55+
countDistinct(column) {
5656
from(table)
5757
run(completer)
58-
})
58+
}.run(mapper)
5959

6060
fun countFrom(mapper: (SelectStatementProvider) -> Long, table: SqlTable, completer: CountCompleter): Long =
61-
mapper(countFrom(table, completer))
61+
countFrom(table, completer).run(mapper)
6262

6363
fun deleteFrom(mapper: (DeleteStatementProvider) -> Int, table: SqlTable, completer: DeleteCompleter): Int =
64-
mapper(deleteFrom(table, completer))
64+
deleteFrom(table, completer).run(mapper)
6565

6666
fun <T : Any> insert(
6767
mapper: (InsertStatementProvider<T>) -> Int,
6868
row: T,
6969
table: SqlTable,
7070
completer: KotlinInsertCompleter<T>
7171
): Int =
72-
mapper(insert(row) {
72+
insert(row) {
7373
into(table)
7474
run(completer)
75-
})
75+
}.run(mapper)
7676

7777
/**
7878
* This function simply inserts all rows using the supplied mapper. It is up
@@ -97,18 +97,18 @@ fun insertInto(
9797
table: SqlTable,
9898
completer: GeneralInsertCompleter
9999
): Int =
100-
mapper(insertInto(table, completer))
100+
insertInto(table, completer).run(mapper)
101101

102102
fun <T : Any> insertMultiple(
103103
mapper: (MultiRowInsertStatementProvider<T>) -> Int,
104104
records: Collection<T>,
105105
table: SqlTable,
106106
completer: KotlinMultiRowInsertCompleter<T>
107107
): Int =
108-
mapper(insertMultiple(records) {
108+
insertMultiple(records) {
109109
into(table)
110110
run(completer)
111-
})
111+
}.run(mapper)
112112

113113
fun <T : Any> insertMultipleWithGeneratedKeys(
114114
mapper: (String, List<T>) -> Int,
@@ -128,40 +128,40 @@ fun insertSelect(
128128
table: SqlTable,
129129
completer: InsertSelectCompleter
130130
): Int =
131-
mapper(insertSelect(table, completer))
131+
insertSelect(table, completer).run(mapper)
132132

133133
fun <T> selectDistinct(
134134
mapper: (SelectStatementProvider) -> List<T>,
135135
selectList: List<BasicColumn>,
136136
table: SqlTable,
137137
completer: SelectCompleter
138138
): List<T> =
139-
mapper(selectDistinct(selectList) {
139+
selectDistinct(selectList) {
140140
from(table)
141141
run(completer)
142-
})
142+
}.run(mapper)
143143

144144
fun <T> selectList(
145145
mapper: (SelectStatementProvider) -> List<T>,
146146
selectList: List<BasicColumn>,
147147
table: SqlTable,
148148
completer: SelectCompleter
149149
): List<T> =
150-
mapper(select(selectList) {
150+
select(selectList) {
151151
from(table)
152152
run(completer)
153-
})
153+
}.run(mapper)
154154

155155
fun <T> selectOne(
156156
mapper: (SelectStatementProvider) -> T?,
157157
selectList: List<BasicColumn>,
158158
table: SqlTable,
159159
completer: SelectCompleter
160160
): T? =
161-
mapper(select(selectList) {
161+
select(selectList) {
162162
from(table)
163163
run(completer)
164-
})
164+
}.run(mapper)
165165

166166
fun update(mapper: (UpdateStatementProvider) -> Int, table: SqlTable, completer: UpdateCompleter): Int =
167-
mapper(update(table, completer))
167+
update(table, completer).run(mapper)

0 commit comments

Comments
 (0)