spring-framework icon indicating copy to clipboard operation
spring-framework copied to clipboard

Add @Sql equivalent support to R2DBC

Open yerzhant opened this issue 4 years ago • 2 comments

@Sql annotation is from jdbc package (org.springframework.test.context.jdbc). Could you please make it more general (from jdbc & r2dbc perspective) so that one can do like this:

@DataR2dbcTest
@Sql("scripts/normalize-sheet.sql")

Right now it gives this exception:

...
java.lang.IllegalStateException: Failed to execute SQL scripts for test context [DefaultTestContext@32a13034 testClass
...
contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.event.ApplicationEventsTestExecutionListener.recordApplicationEvents' -> false]]: supply at least a DataSource or PlatformTransactionManager.

At the moment one of the workarounds is manual script execution: https://stackoverflow.com/a/64118434/4456087

yerzhant avatar Sep 24 '21 19:09 yerzhant

@sbrannen is that something worth considering in spring-test?

mp911de avatar Sep 24 '21 19:09 mp911de

@sbrannen is that something worth considering in spring-test?

Yes, I think so.

And as you pointed out, spring-projects/spring-data-r2dbc#313 is related.

sbrannen avatar Sep 28 '21 13:09 sbrannen

Closing in favor of #34350

bclozel avatar Feb 18 '25 08:02 bclozel