fix(jooq): resolve DSLContext injection ambiguity#1911
Conversation
Co-Authored-By: Codex with GPT-5 <codex@openai.com>
There was a problem hiding this comment.
Pull request overview
Resolves Micronaut jOOQ DSLContext injection ambiguity when both JDBC and R2DBC configurations are present by separating configuration bean types and adjusting DSLContext bean creation/selection.
Changes:
- Introduce distinct internal
JdbcConfigurationandR2dbcConfigurationbean types (both extend jOOQDefaultConfiguration). - Update JDBC/R2DBC configuration factories to return those distinct types and refactor shared configuration setup into a generic helper.
- Create separate
DSLContextbeans for JDBC vs R2DBC configurations and add a regression spec for the combined setup.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
jooq/src/main/java/io/micronaut/configuration/jooq/AbstractJooqConfigurationFactory.java |
Refactors shared configuration wiring into configureConfiguration(T) to support distinct config subtypes. |
jooq/src/main/java/io/micronaut/configuration/jooq/JooqConfigurationFactory.java |
Produces JdbcConfiguration instead of generic Configuration. |
jooq/src/main/java/io/micronaut/configuration/jooq/R2dbcJooqConfigurationFactory.java |
Produces R2dbcConfiguration instead of generic Configuration. |
jooq/src/main/java/io/micronaut/configuration/jooq/JdbcConfiguration.java |
New internal JDBC configuration subtype to disambiguate beans. |
jooq/src/main/java/io/micronaut/configuration/jooq/R2dbcConfiguration.java |
New internal R2DBC configuration subtype to disambiguate beans. |
jooq/src/main/java/io/micronaut/configuration/jooq/DSLContextFactory.java |
Splits DSLContext creation per config type and marks the R2DBC one as primary. |
jooq/src/test/groovy/io/micronaut/configuration/jooq/DslContextFactorySpec.groovy |
Adds regression spec validating default DSLContext injection when both JDBC and R2DBC are present. |
Agent-Logs-Url: https://github.com/micronaut-projects/micronaut-sql/sessions/fc87250f-c4b8-4645-9f7b-dbeb41faa554 Co-authored-by: graemerocher <66626+graemerocher@users.noreply.github.com>
Agent-Logs-Url: https://github.com/micronaut-projects/micronaut-sql/sessions/fc87250f-c4b8-4645-9f7b-dbeb41faa554 Co-authored-by: graemerocher <66626+graemerocher@users.noreply.github.com>
Agent-Logs-Url: https://github.com/micronaut-projects/micronaut-sql/sessions/fc87250f-c4b8-4645-9f7b-dbeb41faa554 Co-authored-by: graemerocher <66626+graemerocher@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
| * @param configuration The {@link Configuration} | ||
| * @return A {@link DSLContext} | ||
| */ | ||
| @EachBean(Configuration.class) |
There was a problem hiding this comment.
Could this cause regression for existing apps where users provide Configuration bean, this might not work then since it will expect Jdbc/R2dbc/Configuration?
This test would fail (passing in 7.0.x)
void "test dsl context is created for custom jooq configuration bean"() {
given:
ApplicationContext applicationContext = ApplicationContext.run("custom-configuration")
expect:
applicationContext.containsBean(Configuration)
applicationContext.containsBean(DSLContext)
applicationContext.getBean(DSLContext).configuration().dialect() == SQLDialect.POSTGRES
cleanup:
applicationContext.close()
}
@Factory
@Requires(env = "custom-configuration")
static class TestFactory {
@Singleton
@Named("default")
Configuration configuration() {
DefaultConfiguration configuration = new DefaultConfiguration()
configuration.setSQLDialect(SQLDialect.POSTGRES)
return configuration
}
}
| @Primary | ||
| @Singleton | ||
| @Requires(beans = R2dbcConfiguration.class) | ||
| DSLContext primaryR2dbcDslContext(@Any BeanProvider<R2dbcConfiguration> configurations) { |
There was a problem hiding this comment.
Could the new primary alias duplicate one DSLContext?
Summary
Verification
Resolves #1292