@@ -254,6 +254,27 @@ class JdbcTest {
254
254
dataSchema.columns[" name" ]!! .type shouldBe typeOf<String >()
255
255
}
256
256
257
+ // to cover a reported case from https://github.com/Kotlin/dataframe/issues/494
258
+ @Test
259
+ fun `repeated read from table with limit` () {
260
+ val tableName = " Customer"
261
+
262
+ for (i in 1 .. 10 ) {
263
+ val df1 = DataFrame .readSqlTable(connection, tableName, 2 ).cast<Customer >()
264
+
265
+ df1.rowsCount() shouldBe 2
266
+ df1.filter { it[Customer ::age] > 30 }.rowsCount() shouldBe 1
267
+ df1[0 ][1 ] shouldBe " John"
268
+
269
+ val dbConfig = DatabaseConfiguration (url = URL )
270
+ val df2 = DataFrame .readSqlTable(dbConfig, tableName, 2 ).cast<Customer >()
271
+
272
+ df2.rowsCount() shouldBe 2
273
+ df2.filter { it[Customer ::age] > 30 }.rowsCount() shouldBe 1
274
+ df2[0 ][1 ] shouldBe " John"
275
+ }
276
+ }
277
+
257
278
@Test
258
279
fun `read from ResultSet` () {
259
280
connection.createStatement(ResultSet .TYPE_SCROLL_SENSITIVE , ResultSet .CONCUR_UPDATABLE ).use { st ->
@@ -306,6 +327,34 @@ class JdbcTest {
306
327
}
307
328
}
308
329
330
+ @Test
331
+ fun `repeated read from ResultSet with limit` () {
332
+ connection.createStatement(ResultSet .TYPE_SCROLL_SENSITIVE , ResultSet .CONCUR_UPDATABLE ).use { st ->
333
+ @Language(" SQL" )
334
+ val selectStatement = " SELECT * FROM Customer"
335
+
336
+ st.executeQuery(selectStatement).use { rs ->
337
+ for (i in 1 .. 10 ) {
338
+ rs.beforeFirst()
339
+
340
+ val df1 = DataFrame .readResultSet(rs, H2 , 2 ).cast<Customer >()
341
+
342
+ df1.rowsCount() shouldBe 2
343
+ df1.filter { it[Customer ::age] > 30 }.rowsCount() shouldBe 1
344
+ df1[0 ][1 ] shouldBe " John"
345
+
346
+ rs.beforeFirst()
347
+
348
+ val df2 = DataFrame .readResultSet(rs, connection, 2 ).cast<Customer >()
349
+
350
+ df2.rowsCount() shouldBe 2
351
+ df2.filter { it[Customer ::age] > 30 }.rowsCount() shouldBe 1
352
+ df2[0 ][1 ] shouldBe " John"
353
+ }
354
+ }
355
+ }
356
+ }
357
+
309
358
@Test
310
359
fun `read from non-existing table` () {
311
360
shouldThrow<JdbcSQLSyntaxErrorException > {
0 commit comments