@@ -10,7 +10,7 @@ import io.r2dbc.spi.Parameter
10
10
import io.r2dbc.spi.Result
11
11
import io.r2dbc.spi.Type
12
12
import mu.KotlinLogging
13
- import org.assertj.core.api.Assertions
13
+ import org.assertj.core.api.Assertions.assertThat
14
14
import org.awaitility.kotlin.await
15
15
import org.hamcrest.core.IsEqual
16
16
import org.junit.Test
@@ -44,15 +44,15 @@ class JasyncR2dbcIntegTest : R2dbcConnectionHelper() {
44
44
.flatMap { result ->
45
45
result
46
46
.map { row, rowMetadata ->
47
- Assertions . assertThat(row.get(" number_tinyint" ) as Byte ).isEqualTo(- 100 )
48
- Assertions . assertThat(row.get(" number_smallint" ) as Short ).isEqualTo(32766 )
49
- Assertions . assertThat(row.get(" number_mediumint" ) as Int ).isEqualTo(8388607 )
50
- Assertions . assertThat(row.get(" number_int" ) as Int ).isEqualTo(2147483647 )
51
- Assertions . assertThat(row.get(" number_bigint" ) as Long ).isEqualTo(9223372036854775807L )
52
- Assertions . assertThat(row.get(" number_decimal" )).isEqualTo(BigDecimal (" 450.764491" ))
53
- Assertions . assertThat(row.get(" number_float" )).isEqualTo(14.7F )
54
- Assertions . assertThat(row.get(" number_double" )).isEqualTo(87650.9876 )
55
- Assertions . assertThat(rowMetadata.columnMetadatas.map { it.name }).isEqualTo(
47
+ assertThat(row.get(" number_tinyint" ) as Byte ).isEqualTo(- 100 )
48
+ assertThat(row.get(" number_smallint" ) as Short ).isEqualTo(32766 )
49
+ assertThat(row.get(" number_mediumint" ) as Int ).isEqualTo(8388607 )
50
+ assertThat(row.get(" number_int" ) as Int ).isEqualTo(2147483647 )
51
+ assertThat(row.get(" number_bigint" ) as Long ).isEqualTo(9223372036854775807L )
52
+ assertThat(row.get(" number_decimal" )).isEqualTo(BigDecimal (" 450.764491" ))
53
+ assertThat(row.get(" number_float" )).isEqualTo(14.7F )
54
+ assertThat(row.get(" number_double" )).isEqualTo(87650.9876 )
55
+ assertThat(rowMetadata.columnMetadatas.map { it.name }).isEqualTo(
56
56
listOf (
57
57
" id" ,
58
58
" number_tinyint" ,
@@ -78,8 +78,8 @@ class JasyncR2dbcIntegTest : R2dbcConnectionHelper() {
78
78
withConnection { c ->
79
79
var filtering = 0
80
80
var rows = 0
81
- executeQuery(c, createTable )
82
- executeQuery(c, """ INSERT INTO users (name) VALUES ('Boogie Man'),('Dambeldor') """ )
81
+ executeQuery(c, createUserTable )
82
+ executeQuery(c, insertUsers )
83
83
val cf = createJasyncConnectionFactory(c)
84
84
Mono .from(cf.create())
85
85
.flatMapMany { connection ->
@@ -109,8 +109,8 @@ class JasyncR2dbcIntegTest : R2dbcConnectionHelper() {
109
109
fun `bind test` () {
110
110
withConnection { c ->
111
111
var rows = 0
112
- executeQuery(c, createTable )
113
- executeQuery(c, """ INSERT INTO users (name) VALUES ('Boogie Man'),('Dambeldor') """ )
112
+ executeQuery(c, createUserTable )
113
+ executeQuery(c, insertUsers )
114
114
val cf = createJasyncConnectionFactory(c)
115
115
Mono .from(cf.create())
116
116
.flatMapMany { connection ->
@@ -139,8 +139,8 @@ class JasyncR2dbcIntegTest : R2dbcConnectionHelper() {
139
139
fun `bind test for parametrized` () {
140
140
withConnection { c ->
141
141
var rows = 0
142
- executeQuery(c, createTable )
143
- executeQuery(c, """ INSERT INTO users (name) VALUES ('Boogie Man'),('Dambeldor') """ )
142
+ executeQuery(c, createUserTable )
143
+ executeQuery(c, insertUsers )
144
144
val cf = createJasyncConnectionFactory(c)
145
145
Mono .from(cf.create())
146
146
.flatMapMany { connection ->
@@ -164,6 +164,41 @@ class JasyncR2dbcIntegTest : R2dbcConnectionHelper() {
164
164
}
165
165
}
166
166
167
+ @Test
168
+ fun `join tables which have column with the same names test` () {
169
+ withConnection { c ->
170
+ var rows = 0
171
+ executeQuery(c, createUserTable)
172
+ executeQuery(c, insertUsers)
173
+ executeQuery(c, createPostTable)
174
+ executeQuery(c, insertPosts)
175
+ val cf = createJasyncConnectionFactory(c)
176
+ Mono .from(cf.create())
177
+ .flatMapMany { connection ->
178
+ connection
179
+ .createStatement(" SELECT * FROM users JOIN posts ON users.id = posts.user_id" )
180
+ .execute()
181
+ }
182
+ .flatMap { result ->
183
+ result
184
+ .map { row, rowMetadata ->
185
+ assertThat(rowMetadata.columnMetadatas.map { it.name }).isEqualTo(
186
+ listOf (
187
+ " id" ,
188
+ " name" ,
189
+ " id" ,
190
+ " title" ,
191
+ " user_id" ,
192
+ )
193
+ )
194
+ }
195
+ }
196
+ .doOnNext { rows++ }
197
+ .subscribe()
198
+ await.until { rows == 2 }
199
+ }
200
+ }
201
+
167
202
private fun String.createParam (): Parameter = object : Parameter {
168
203
override fun getType (): Type {
169
204
TODO (" Not implemented" )
0 commit comments