Skip to content

Commit cddbccd

Browse files
committed
Consistent use of infix
1 parent 7ba9050 commit cddbccd

File tree

6 files changed

+92
-85
lines changed

6 files changed

+92
-85
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2021 the original author or authors.
2+
* Copyright 2016-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -49,21 +49,23 @@ interface GeneratedAlwaysMapper {
4949

5050
fun GeneratedAlwaysMapper.insert(record: GeneratedAlwaysRecord): Int {
5151
return insert(this::insert, record, generatedAlways) {
52-
map(firstName).toProperty("firstName")
53-
map(lastName).toProperty("lastName")
52+
map(firstName) toProperty "firstName"
53+
map(lastName) toProperty "lastName"
5454
}
5555
}
5656

57+
fun GeneratedAlwaysMapper.insertMultiple(vararg records: GeneratedAlwaysRecord): Int = insertMultiple(records.asList())
58+
5759
fun GeneratedAlwaysMapper.insertMultiple(records: Collection<GeneratedAlwaysRecord>): Int {
5860
return insertMultipleWithGeneratedKeys(this::insertMultiple, records, generatedAlways) {
59-
map(firstName).toProperty("firstName")
60-
map(lastName).toProperty("lastName")
61+
map(firstName) toProperty "firstName"
62+
map(lastName) toProperty "lastName"
6163
}
6264
}
6365

6466
fun GeneratedAlwaysMapper.insertBatch(records: Collection<GeneratedAlwaysRecord>): List<Int> {
6567
return insertBatch(this::insert, records, generatedAlways) {
66-
map(firstName).toProperty("firstName")
67-
map(lastName).toProperty("lastName")
68+
map(firstName) toProperty "firstName"
69+
map(lastName) toProperty "lastName"
6870
}
6971
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class GeneratedAlwaysTest {
8484
lastName = "Rubble"
8585
)
8686

87-
val rows = mapper.insertMultiple(listOf(record1, record2))
87+
val rows = mapper.insertMultiple(record1, record2)
8888

8989
assertThat(rows).isEqualTo(2)
9090
assertThat(record1.id).isEqualTo(22)

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ fun PersonMapper.deleteByPrimaryKey(id_: Int) =
6565

6666
fun PersonMapper.insert(record: PersonRecord) =
6767
insert(this::insert, record, person) {
68-
map(id).toProperty("id")
69-
map(firstName).toProperty("firstName")
70-
map(lastName).toProperty("lastName")
71-
map(birthDate).toProperty("birthDate")
72-
map(employed).toProperty("employed")
73-
map(occupation).toProperty("occupation")
74-
map(addressId).toProperty("addressId")
68+
map(id) toProperty "id"
69+
map(firstName) toProperty "firstName"
70+
map(lastName) toProperty "lastName"
71+
map(birthDate) toProperty "birthDate"
72+
map(employed) toProperty "employed"
73+
map(occupation) toProperty "occupation"
74+
map(addressId) toProperty "addressId"
7575
}
7676

7777
fun PersonMapper.generalInsert(completer: GeneralInsertCompleter) =
@@ -85,27 +85,27 @@ fun PersonMapper.insertBatch(vararg records: PersonRecord): List<Int> =
8585

8686
fun PersonMapper.insertBatch(records: Collection<PersonRecord>): List<Int> =
8787
insertBatch(this::insert, records, person) {
88-
map(id).toProperty("id")
89-
map(firstName).toProperty("firstName")
90-
map(lastName).toProperty("lastName")
91-
map(birthDate).toProperty("birthDate")
92-
map(employed).toProperty("employed")
93-
map(occupation).toProperty("occupation")
94-
map(addressId).toProperty("addressId")
88+
map(id) toProperty "id"
89+
map(firstName) toProperty "firstName"
90+
map(lastName) toProperty "lastName"
91+
map(birthDate) toProperty "birthDate"
92+
map(employed) toProperty "employed"
93+
map(occupation) toProperty "occupation"
94+
map(addressId) toProperty "addressId"
9595
}
9696

9797
fun PersonMapper.insertMultiple(vararg records: PersonRecord) =
9898
insertMultiple(records.toList())
9999

100100
fun PersonMapper.insertMultiple(records: Collection<PersonRecord>) =
101101
insertMultiple(this::insertMultiple, records, person) {
102-
map(id).toProperty("id")
103-
map(firstName).toProperty("firstName")
104-
map(lastName).toProperty("lastName")
105-
map(birthDate).toProperty("birthDate")
106-
map(employed).toProperty("employed")
107-
map(occupation).toProperty("occupation")
108-
map(addressId).toProperty("addressId")
102+
map(id) toProperty "id"
103+
map(firstName) toProperty "firstName"
104+
map(lastName) toProperty "lastName"
105+
map(birthDate) toProperty "birthDate"
106+
map(employed) toProperty "employed"
107+
map(occupation) toProperty "occupation"
108+
map(addressId) toProperty "addressId"
109109
}
110110

111111
fun PersonMapper.insertSelective(record: PersonRecord) =

src/test/kotlin/examples/kotlin/mybatis3/custom/render/KCustomRenderingTest.kt

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ import org.junit.jupiter.api.Test
3131
import org.junit.jupiter.api.TestInstance
3232
import org.mybatis.dynamic.sql.SqlColumn
3333
import org.mybatis.dynamic.sql.util.kotlin.elements.`as`
34-
import org.mybatis.dynamic.sql.util.kotlin.elements.insert
35-
import org.mybatis.dynamic.sql.util.kotlin.elements.insertMultiple
3634
import org.mybatis.dynamic.sql.util.kotlin.mybatis3.deleteFrom
35+
import org.mybatis.dynamic.sql.util.kotlin.mybatis3.insert
3736
import org.mybatis.dynamic.sql.util.kotlin.mybatis3.insertInto
38-
import org.mybatis.dynamic.sql.util.kotlin.mybatis3.into
37+
import org.mybatis.dynamic.sql.util.kotlin.mybatis3.insertMultiple
3938
import org.mybatis.dynamic.sql.util.kotlin.mybatis3.select
4039
import org.mybatis.dynamic.sql.util.kotlin.mybatis3.update
4140
import org.mybatis.dynamic.sql.util.mybatis3.CommonSelectMapper
@@ -84,10 +83,11 @@ class KCustomRenderingTest {
8483
info = "{\"firstName\": \"Fred\", \"lastName\": \"Flintstone\", \"age\": 30}"
8584
)
8685

87-
var insertStatement = insert(record).into(jsonTest) {
88-
map(id).toProperty("id")
89-
map(description).toProperty("description")
90-
map(info).toProperty("info")
86+
var insertStatement = insert(record) {
87+
into(jsonTest)
88+
map(id) toProperty "id"
89+
map(description) toProperty "description"
90+
map(info) toProperty "info"
9191
}
9292
val expected = "insert into JsonTest (id, description, info) " +
9393
"values (#{record.id,jdbcType=INTEGER}, #{record.description,jdbcType=VARCHAR}, " +
@@ -101,10 +101,11 @@ class KCustomRenderingTest {
101101
info = "{\"firstName\": \"Wilma\", \"lastName\": \"Flintstone\", \"age\": 25}"
102102
)
103103

104-
insertStatement = insert(record).into(jsonTest) {
105-
map(id).toProperty("id")
106-
map(description).toProperty("description")
107-
map(info).toProperty("info")
104+
insertStatement = insert(record) {
105+
into(jsonTest)
106+
map(id) toProperty "id"
107+
map(description) toProperty "description"
108+
map(info) toProperty "info"
108109
}
109110
rows = mapper.insert(insertStatement)
110111
assertThat(rows).isEqualTo(1)
@@ -170,10 +171,11 @@ class KCustomRenderingTest {
170171
description = "Wilma",
171172
info = "{\"firstName\": \"Wilma\", \"lastName\": \"Flintstone\", \"age\": 25}"
172173
)
173-
val insertStatement = insertMultiple(record1, record2).into(jsonTest) {
174-
map(id).toProperty("id")
175-
map(description).toProperty("description")
176-
map(info).toProperty("info")
174+
val insertStatement = insertMultiple(listOf(record1, record2)) {
175+
into(jsonTest)
176+
map(id) toProperty "id"
177+
map(description) toProperty "description"
178+
map(info) toProperty "info"
177179
}
178180
val expected = "insert into JsonTest (id, description, info) " +
179181
"values (#{records[0].id,jdbcType=INTEGER}, #{records[0].description,jdbcType=VARCHAR}, " +
@@ -210,10 +212,11 @@ class KCustomRenderingTest {
210212
description = "Wilma",
211213
info = "{\"firstName\": \"Wilma\", \"lastName\": \"Flintstone\", \"age\": 25}"
212214
)
213-
val insertStatement = insertMultiple(record1, record2).into(jsonTest) {
214-
map(id).toProperty("id")
215-
map(description).toProperty("description")
216-
map(info).toProperty("info")
215+
val insertStatement = insertMultiple(listOf(record1, record2)) {
216+
into(jsonTest)
217+
map(id) toProperty "id"
218+
map(description) toProperty "description"
219+
map(info) toProperty "info"
217220
}
218221
var rows = mapper.insertMultiple(insertStatement)
219222
assertThat(rows).isEqualTo(2)
@@ -254,10 +257,11 @@ class KCustomRenderingTest {
254257
description = "Wilma",
255258
info = "{\"firstName\": \"Wilma\", \"lastName\": \"Flintstone\", \"age\": 25}"
256259
)
257-
val insertStatement = insertMultiple(record1, record2).into(jsonTest) {
258-
map(id).toProperty("id")
259-
map(description).toProperty("description")
260-
map(info).toProperty("info")
260+
val insertStatement = insertMultiple(listOf(record1, record2)) {
261+
into(jsonTest)
262+
map(id) toProperty "id"
263+
map(description) toProperty "description"
264+
map(info) toProperty "info"
261265
}
262266
val rows = mapper.insertMultiple(insertStatement)
263267
assertThat(rows).isEqualTo(2)
@@ -291,10 +295,11 @@ class KCustomRenderingTest {
291295
description = "Wilma",
292296
info = "{\"firstName\": \"Wilma\", \"lastName\": \"Flintstone\", \"age\": 25}"
293297
)
294-
val insertStatement = insertMultiple(record1, record2).into(jsonTest) {
295-
map(id).toProperty("id")
296-
map(description).toProperty("description")
297-
map(info).toProperty("info")
298+
val insertStatement = insertMultiple(listOf(record1, record2)) {
299+
into(jsonTest)
300+
map(id) toProperty "id"
301+
map(description) toProperty "description"
302+
map(info) toProperty "info"
298303
}
299304
val rows = mapper.insertMultiple(insertStatement)
300305
assertThat(rows).isEqualTo(2)

src/test/kotlin/examples/kotlin/spring/canonical/CanonicalSpringKotlinTemplateDirectTest.kt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,13 @@ open class CanonicalSpringKotlinTemplateDirectTest {
229229

230230
val rows = template.insertMultiple(record1, record2) {
231231
into(person)
232-
map(id).toProperty("id")
233-
map(firstName).toProperty("firstName")
234-
map(lastName).toProperty("lastNameAsString")
235-
map(birthDate).toProperty("birthDate")
236-
map(employed).toProperty("employedAsString")
237-
map(occupation).toProperty("occupation")
238-
map(addressId).toProperty("addressId")
232+
map(id) toProperty "id"
233+
map(firstName) toProperty "firstName"
234+
map(lastName) toProperty "lastNameAsString"
235+
map(birthDate) toProperty "birthDate"
236+
map(employed) toProperty "employedAsString"
237+
map(occupation) toProperty "occupation"
238+
map(addressId) toProperty "addressId"
239239
}
240240

241241
assertThat(rows).isEqualTo(2)
@@ -266,13 +266,13 @@ open class CanonicalSpringKotlinTemplateDirectTest {
266266

267267
val rows = template.insertBatch(record1, record2) {
268268
into(person)
269-
map(id).toProperty("id")
270-
map(firstName).toProperty("firstName")
271-
map(lastName).toProperty("lastNameAsString")
272-
map(birthDate).toProperty("birthDate")
273-
map(employed).toProperty("employedAsString")
274-
map(occupation).toProperty("occupation")
275-
map(addressId).toProperty("addressId")
269+
map(id) toProperty "id"
270+
map(firstName) toProperty "firstName"
271+
map(lastName) toProperty "lastNameAsString"
272+
map(birthDate) toProperty "birthDate"
273+
map(employed) toProperty "employedAsString"
274+
map(occupation) toProperty "occupation"
275+
map(addressId) toProperty "addressId"
276276
}
277277

278278
assertThat(rows).hasSize(2)
@@ -359,8 +359,8 @@ open class CanonicalSpringKotlinTemplateDirectTest {
359359
val rows = template.withKeyHolder(keyHolder) {
360360
insert(command) {
361361
into(generatedAlways)
362-
map(generatedAlways.firstName).toProperty("firstName")
363-
map(generatedAlways.lastName).toProperty("lastName")
362+
map(generatedAlways.firstName) toProperty "firstName"
363+
map(generatedAlways.lastName) toProperty "lastName"
364364
}
365365
}
366366

@@ -399,8 +399,8 @@ open class CanonicalSpringKotlinTemplateDirectTest {
399399
val rows = template.withKeyHolder(keyHolder) {
400400
insertMultiple(command1, command2) {
401401
into(generatedAlways)
402-
map(generatedAlways.firstName).toProperty("firstName")
403-
map(generatedAlways.lastName).toProperty("lastName")
402+
map(generatedAlways.firstName) toProperty "firstName"
403+
map(generatedAlways.lastName) toProperty "lastName"
404404
}
405405
}
406406

src/test/kotlin/examples/kotlin/spring/canonical/CanonicalSpringKotlinTest.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -455,13 +455,13 @@ open class CanonicalSpringKotlinTest {
455455

456456
val insertStatement = insertBatch(listOf(record1, record2)) {
457457
into(person)
458-
map(id).toProperty("id")
459-
map(firstName).toProperty("firstName")
460-
map(lastName).toProperty("lastNameAsString")
461-
map(birthDate).toProperty("birthDate")
462-
map(employed).toProperty("employedAsString")
463-
map(occupation).toProperty("occupation")
464-
map(addressId).toProperty("addressId")
458+
map(id) toProperty "id"
459+
map(firstName) toProperty "firstName"
460+
map(lastName) toProperty "lastNameAsString"
461+
map(birthDate) toProperty "birthDate"
462+
map(employed) toProperty "employedAsString"
463+
map(occupation) toProperty "occupation"
464+
map(addressId) toProperty "addressId"
465465
}
466466

467467
val rows = template.insertBatch(insertStatement)
@@ -588,8 +588,8 @@ open class CanonicalSpringKotlinTest {
588588

589589
val insertStatement = insert(command) {
590590
into(generatedAlways)
591-
map(generatedAlways.firstName).toProperty("firstName")
592-
map(generatedAlways.lastName).toProperty("lastName")
591+
map(generatedAlways.firstName) toProperty "firstName"
592+
map(generatedAlways.lastName) toProperty "lastName"
593593
}
594594

595595
val keyHolder = GeneratedKeyHolder()
@@ -608,8 +608,8 @@ open class CanonicalSpringKotlinTest {
608608

609609
val insertStatement = insertMultiple(listOf(command1, command2)) {
610610
into(generatedAlways)
611-
map(generatedAlways.firstName).toProperty("firstName")
612-
map(generatedAlways.lastName).toProperty("lastName")
611+
map(generatedAlways.firstName) toProperty "firstName"
612+
map(generatedAlways.lastName) toProperty "lastName"
613613
}
614614

615615
val keyHolder = GeneratedKeyHolder()

0 commit comments

Comments
 (0)