spring-projects / spring-projects/spring-data-ldap

Predicate fails with message: Unsupported operator IN [DATALDAP-62]

Open
#82 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: ideal-for-contribution type: bug
Dominant language
Java
Stars
96
Forks
64
PR merge metrics
No merged PRs in 30d

Description

Alex opened DATALDAP-62 and commented

I have a POJO class that contains LDAP attributes. The class is annotated with @Entry annotation. The entity has some fields as a collection (i.e. Set<String>) but most of the POJO fields are just String values.
When I try to use LdapRepository's findAll method with Predicate to search through multi-valued fields with using Collection.contains(...) method the spring-data-ldap throws the exception:

java.lang.UnsupportedOperationException: Unsupported operator IN
at org.springframework.data.ldap.repository.support.LdapSerializer.visit(LdapSerializer.java:108)
at org.springframework.data.ldap.repository.support.LdapSerializer.visit(LdapSerializer.java:37)
at com.querydsl.core.types.OperationImpl.accept(OperationImpl.java:83)

I was able to trace the problem and it looks like when Collection type of an attribute is used for a Predicate's query then QueryDSL provides IN operation which is not supported by Spring's LdapSerializer class.
Here is the sample of the Predicate:

QPerson person = QPerson.person;
return person.studentAliases.contains(alias).or(person.employeeAliases.contains(alias));

Is it possible to add support for IN operation same way as EQ operator so DATA-LDAP module processes multi-valued attributes without any issues?


No further details from DATALDAP-62

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in org.springframework.data.ldap.repository.support.LdapSerializer, especially visit at lines 108 and 37, and trace how the QueryDSL contains predicate becomes the IN operation. Compare the unsupported IN handling with EQ handling, using the QPerson studentAliases and employeeAliases example. Done means collection-based predicates are serialized without the UnsupportedOperationException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.