Skip to content

Preserve textual operator arguments - #206

Merged
ng-galien merged 1 commit into
perplexhub:masterfrom
ng-galien:fix/preserve-textual-operator-arguments
Jun 2, 2026
Merged

ng-galien merged 1 commit into
perplexhub:masterfrom
ng-galien:fix/preserve-textual-operator-arguments

Conversation

@ng-galien

Copy link
Copy Markdown
Collaborator

Hi @perplexhub, @nstdio,

While using the lib on UUID fields, we ran into an issue with =ilike= on UUID attributes.

There are actually two related failure modes:

  • partial textual values are converted too early to the Java field type, so a query like externalId=ilike='AAAAAAAA' fails with a ConversionException: Failed to convert ... to java.util.UUID type;
  • on PostgreSQL, even a full UUID value fails because the generated SQL applies LIKE directly to a UUID column, which raises PSQLException: ERROR: operator does not exist: uuid ~~ text.

This PR keeps the RSQL argument as text for textual operators, and casts the expression side to text when building LIKE / ILIKE / ICASE predicates. With Hibernate/PostgreSQL this now produces the expected SQL shape:

cast(users.external_id as varchar) like ?

I kept the patch narrow and added coverage for:

  • the invariant deciding which operators preserve textual arguments;
  • UUID fields with like, notlike, icase, ilike, inotlike;
  • the PostgreSQL exact UUID like case.

mvn clean verify is green locally.

Do you see any potential breaking change with this behavior, especially for existing non-String fields using textual operators?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts RSQL predicate building so textual operators (LIKE/ILIKE/ICASE and negations) keep the raw RSQL argument as text and cast the expression side to String, fixing failures when applying textual operators to non-String fields (notably UUID) and ensuring PostgreSQL generates cast(column as varchar) like ?-style SQL.

Changes:

  • Preserve raw (string) RSQL arguments for textual operators instead of converting them to the attribute Java type.
  • Cast expressions to String when building LIKE/ILIKE/ICASE predicates (including JSON-path string comparisons).
  • Add test coverage for UUID like/ilike behavior (H2 + PostgreSQL) and for the operator-invariant.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
rsql-jpa/src/main/java/io/github/perplexhub/rsql/RSQLJPAPredicateConverter.java Preserve textual arguments for textual operators; cast expressions to String for textual predicates.
rsql-jpa/src/test/java/io/github/perplexhub/rsql/RSQLJPASupportTest.java Adds H2-backed tests for UUID fields with textual operators.
rsql-jpa/src/test/java/io/github/perplexhub/rsql/RSQLJPASupportPostgresJsonTest.java Adds PostgreSQL regression test for UUID LIKE on UUID column; extends cleanup logic.
rsql-jpa/src/test/java/io/github/perplexhub/rsql/RSQLJPAPredicateConverterTest.java Adds unit test for the textual-argument-preservation operator set.
rsql-common/src/test/resources/import_user.sql Seeds external_id values needed for UUID textual-operator tests.
rsql-common/src/test/java/io/github/perplexhub/rsql/model/User.java Adds externalId UUID field to the test User entity.

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

Comment on lines 69 to 76
private void clear() {
userRepository.deleteAll();
userRepository.flush();
repository.deleteAll();
repository.flush();
entityWithJsonbRepository.deleteAll();
entityWithJsonbRepository.flush();
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, good catch. I updated the cleanup to clear JsonbEntity and AnotherJsonbEntity as well, deleting EntityWithJsonb first to respect the relation. RSQLJPASupportPostgresJsonTest passes locally: 242 tests, 0 failures.

@ng-galien
ng-galien force-pushed the fix/preserve-textual-operator-arguments branch from fd98234 to a405ec1 Compare June 2, 2026 11:06
@ng-galien
ng-galien merged commit 8e1410e into perplexhub:master Jun 2, 2026
1 check passed
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.

3 participants