Skip to content

Commit ec66562

Browse files
committed
Add missing allRows convenience method
1 parent f7b7741 commit ec66562

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2019 the original author or authors.
2+
* Copyright 2016-2020 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.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2019 the original author or authors.
2+
* Copyright 2016-2020 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.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class KotlinUnionFromGatherer(private val fromGatherer: QueryExpressionDSL.FromG
4646
class KotlinUnionQueryBuilder(private val unionDsl: QueryExpressionDSL<SelectModel>) :
4747
KotlinBaseJoiningBuilder<QueryExpressionDSL<SelectModel>, QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder,
4848
KotlinUnionQueryBuilder>(unionDsl) {
49+
fun allRows() = this
50+
4951
override fun self() = this
5052

5153
override fun getWhere(): QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder = unionDsl.where()

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -599,9 +599,10 @@ class CanonicalSpringKotlinTest {
599599
id.`as`("A_ID"), firstName, lastName, birthDate, employed, occupation,
600600
addressId
601601
).from(Person, "p") {
602-
where(id, isEqualTo(3))
602+
allRows()
603603
}
604604
}
605+
orderBy(sortColumn("A_ID"))
605606
}
606607

607608
val expected = "select id as A_ID, first_name, last_name, birth_date, employed, occupation, address_id " +
@@ -614,7 +615,7 @@ class CanonicalSpringKotlinTest {
614615
"union all " +
615616
"select distinct p.id as A_ID, p.first_name, p.last_name, p.birth_date, p.employed, p.occupation, p.address_id " +
616617
"from Person p " +
617-
"where p.id = :p3"
618+
"order by A_ID"
618619

619620
assertThat(selectStatement.selectStatement).isEqualTo(expected)
620621

@@ -630,7 +631,7 @@ class CanonicalSpringKotlinTest {
630631
record
631632
}
632633

633-
assertThat(records).hasSize(3)
634+
assertThat(records).hasSize(8)
634635
with(records[0]) {
635636
assertThat(id).isEqualTo(1)
636637
assertThat(firstName).isEqualTo("Fred")
@@ -642,12 +643,12 @@ class CanonicalSpringKotlinTest {
642643
}
643644

644645
with(records[2]) {
645-
assertThat(id).isEqualTo(3)
646-
assertThat(firstName).isEqualTo("Pebbles")
646+
assertThat(id).isEqualTo(2)
647+
assertThat(firstName).isEqualTo("Wilma")
647648
assertThat(lastName).isEqualTo("Flintstone")
648649
assertThat(birthDate).isNotNull()
649-
assertThat(employed).isEqualTo("No")
650-
assertThat(occupation).isNull()
650+
assertThat(employed).isEqualTo("Yes")
651+
assertThat(occupation).isEqualTo("Accountant")
651652
assertThat(addressId).isEqualTo(1)
652653
}
653654
}

0 commit comments

Comments
 (0)