Skip to content

Add per-query ConversionService support#208

Open
ggomarighetti wants to merge 6 commits into
perplexhub:masterfrom
ggomarighetti:codex/per-query-conversion-service
Open

Add per-query ConversionService support#208
ggomarighetti wants to merge 6 commits into
perplexhub:masterfrom
ggomarighetti:codex/per-query-conversion-service

Conversation

@ggomarighetti
Copy link
Copy Markdown

Resume

This PR adds optional per-query ConversionService support for RSQL predicate conversion.

Today, custom value converters are registered through RSQLJPASupport.addConverter(...), which mutates the static conversion service owned by RSQLCommonSupport. That works for simple applications, but it makes conversion rules JVM-global. Applications that run multiple Spring contexts, execute tests in parallel, use application-specific value objects, or validate RSQL before delegating execution cannot guarantee that the conversion rules used during validation are the same rules used later by Specification.toPredicate(...).

The change keeps the current global converter registry as the backward-compatible fallback, while allowing callers to pass a query-specific ConversionService:

Specification<User> spec = RSQLJPASupport.toSpecification(QuerySupport.builder()
    .rsqlQuery("customerId==ACME-42")
    .propertyPathMapper(paths)
    .conversionService(applicationConversionService)
    .build());

Conversion now follows this order:

  1. Query or visitor instance ConversionService, when present and able to convert.
  2. Existing global defaultConversionService, preserving addConverter(...) behavior.
  3. Existing built-in conversion fallbacks.

The same conversion path is used by default JPA operators and JPA custom predicates. QueryDSL also gets a new overload that accepts a per-query ConversionService.

Evidence

Not required

Reference

Closes #207

Copilot AI review requested due to automatic review settings June 7, 2026 12:58
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds support for a per-query Spring ConversionService so conversions can be isolated per request/query and take precedence over the library-wide (static) converter registry.

Changes:

  • Add ConversionService plumbing to RSQLVisitorBase and thread it through JPA + QueryDSL predicate/spec builders.
  • Extend QuerySupport to carry a per-query ConversionService.
  • Add tests and README documentation describing precedence and usage.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
rsql-querydsl/src/test/java/io/github/perplexhub/rsql/RSQLQueryDslSupportTest.java Adds a test ensuring a per-query ConversionService is preferred for QueryDSL predicates.
rsql-querydsl/src/main/java/io/github/perplexhub/rsql/RSQLQueryDslSupport.java Adds a new toPredicate overload that accepts a ConversionService.
rsql-querydsl/src/main/java/io/github/perplexhub/rsql/RSQLQueryDslPredicateConverter.java Adds constructor overload to inject/set a per-query ConversionService.
rsql-jpa/src/test/java/io/github/perplexhub/rsql/RSQLJPASupportTest.java Adds tests ensuring QuerySupport.conversionService takes precedence (including for custom predicates).
rsql-jpa/src/main/java/io/github/perplexhub/rsql/RSQLJPASupport.java Passes QuerySupport’s ConversionService into the JPA predicate converter.
rsql-jpa/src/main/java/io/github/perplexhub/rsql/RSQLJPAPredicateConverter.java Adds constructor overload to accept and set ConversionService.
rsql-jpa/src/main/java/io/github/perplexhub/rsql/QuerySupport.java Adds conversionService field + includes it in toString().
rsql-common/src/test/java/io/github/perplexhub/rsql/RSQLVisitorBaseTest.java Adds tests for precedence/fallback between instance and global conversion services.
rsql-common/src/main/java/io/github/perplexhub/rsql/RSQLVisitorBase.java Implements instance ConversionService precedence in convert(...).
README.md Documents global vs per-query conversion behavior and usage examples.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ggomarighetti
Copy link
Copy Markdown
Author

Hi @perplexhub, @nstdio,

I opened this PR as a follow-up to #207 to add optional per-query ConversionService support while keeping the current global converter registry as the backward-compatible fallback.

The goal is to let applications isolate conversion rules per query/context without changing existing behavior for users who rely on RSQLJPASupport.addConverter(...).

I also included focused tests for the common conversion path, JPA default operators, JPA custom predicates, and QueryDSL. I would appreciate your review or guidance if you prefer a narrower scope or a different API shape.

Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support per-query ConversionService for isolated RSQL argument conversion

2 participants