Skip to content

Support for dynamic path in QuerydslPredicateBuilder [DATACMNS-1093] #1536

@spring-projects-issues

Description

@spring-projects-issues

Andrii Ivanenko opened DATACMNS-1093 and commented

In the case when property is declared as Object and for example Map is mostly used, it's not possible to filter against map keys.

private Object value;

When executing query with predicate

Expressions.stringPath("value.key1").eq("val1")

it returns correct results, but when trying to integrate with QuerydslPredicateBuilder there are problems.

In repository I've declared:

bindings.bind(Expressions.stringPath(QData.data.value, "key1")).as("k1").first((path, value) -> path.contains(value));

but exception is thrown in getTargetTypeDescriptor().

It would be great to have possibility at least to override method convertToPropertyPathSpecificType(), so developer can have control over converting values for custom paths


Affects: 1.13.4 (Ingalls SR4)

Activity

spring-projects-issues

spring-projects-issues commented on Jun 19, 2017

@spring-projects-issues
Author

Oliver Drotbohm commented

I am not sure I totally get the scenario. Would you mind adding a small boot app that contains a failing test that shows what you're trying to achieve?

spring-projects-issues

spring-projects-issues commented on Jun 19, 2017

@spring-projects-issues
Author

Andrii Ivanenko commented

Here is an example https://github.com/andrii-NIX/dynamic-path-test
Main goal is to be able to query against Map keys for the property that is declared as Object. In current implementation it fails after trying to get field key1 in Object using reflection.

So in QuerydslPredicateBuilder#convertToPropertyPathSpecificType() I'd like to change the behavior and skip converting String -> String.

By the way in line 192 canConvert() condition is always true, returning no-op converter for the missing types.
Thanks

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

Metadata

Metadata

Assignees

Labels

in: webIntegration with Spring MVCtype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @odrotbohm@spring-projects-issues

      Issue actions

        Support for dynamic path in QuerydslPredicateBuilder [DATACMNS-1093] · Issue #1536 · spring-projects/spring-data-commons