Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing configuration in Multiset #16655

Open
eralmansouri opened this issue May 7, 2024 · 1 comment
Open

Missing configuration in Multiset #16655

eralmansouri opened this issue May 7, 2024 · 1 comment

Comments

@eralmansouri
Copy link

eralmansouri commented May 7, 2024

Expected behavior

I'm using JOOQ with Spring Boot and I initialize the Configuration with some data. eg:

@Bean
DefaultConfigurationCustomizer jooqConfigCustomize() {
    return configuration -> {
        configuration.data("KEY_FOR_DATA", new ExampleDecryptor(key));
    };
}

I would expect this configuration data to be present in all areas that I try to read from config at any stage of a select query.

Actual behavior

I have a ContextConverter that uses that data by reading it from ctx.configuration() as described here.

@Slf4j
public class ExampleDecryptor<J, U> extends AbstractContextConverter<J, U> {
    public static final String CONTEXT_KEY = "KEY_FOR_DATA";

    private Object readFromCtx(ConverterContext ctx) {
        return ctx.configuration().data(CONTEXT_KEY);
    }

    // ... other code
}

The issue is, if I use a multiset query, the sub-select statement uses DSL.select() once more with the default configuration and I lose access to that data during conversion, preventing my access to that data. Even more, because it reverts back to default configuration, I am struggling to even override the providers.

Steps to reproduce the problem

As an example, let's say I have this query.

dsl.select(USER, USER.profile().PICTURE, USER.profile().JOB_RESUME,
      dsl.select(JOB_APPLICATION)
          .from(JOB_APPLICATION)
          .where(USER.ID.eq(JOB_APPLICATION.APPLICANT_ID))
          .asMultiset()
          .convertFrom(r -> r.map(mapping(JobApplicationImpl::new)))
  )
  .from(USER)
  .where(USER.ID.eq(userId))

The converter example above will have the data it needs from configuration() while converting the user fields or picture but will fail during conversion of job application fields due to reverting to Jooq's default configuration.

jOOQ Version

3.19.8

Database product and version

PostgreSQL 16.2 (Debian 16.2-1.pgdg120+2) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit

Java Version

21

JDBC / R2DBC driver name and version (include name if unofficial driver)

org.postgresql:postgresql:42.6.1

@lukaseder
Copy link
Member

Thank you very much for your report. I'll look into this soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants