The only problem is that there's no way to provide...
# komapper
d
The only problem is that there's no way to provide a dialect w/o a real connection?
It looks like this works, is this correct? (As long as I don't create a JdbcDatabase out of it, it shouldn't require a connection, but it should provide komapper's querydsl enough information to adapt the queries to the proper dialect?)
Copy code
val dataSource: DataSource = SimpleDataSource("")
val dialect: JdbcDialect = MySqlJdbcDialect()
val config: JdbcDatabaseConfig = object: DefaultJdbcDatabaseConfig(dataSource, dialect) {}

// pass config to dryRun()
Although maybe there should be a better way to do this? Why can't I just pass a JdbcDialect (or maybe even some more generic base class, since dialect probably has nothing to do with how to connect to the db - jdbc/r2dbc?)?
t
It looks like this works, is this correct?
Yes. But, creating a JdbcDatabase alone does not create a Connection, so it can be written as follows:
Copy code
val dummyDb = JdbcDatabase("jdbc:<mysql://dummy/dummy>")
val dummyConfig = dummyDb.config
val query = QueryDsl.from(Meta.employee)
val result = query.dryRun(dummyConfig)
d
@Toshihiro Nakamura I'm trying to continue with this idea by making an R2dbcDatabase implementation that uses Jasync to run the queries to ease migration to Komapper in an existing project. Using dryRun is great for this, but is there any way I can re-use komapper's mapping to the result entity/list/... just by transforming Jasync's result to something komapper can use to return whatever it needs to?
It looks like what I'm looking for is
R2dbcRowTransformers
but it's internal, and seems not to simple to make an adapter for... it's really much more oriented to R2dbc...
t
Do you really need an R2dbcDatabase implementation? You may use the Repository pattern to absorb the differences between Komapper and Jasync.
d
It's really because I want to unit test the repositories with H2 and also have integration tests with testcontainers, so I need that the connection be shared between the test code and the repository...