spring-data-rest icon indicating copy to clipboard operation
spring-data-rest copied to clipboard

SortTranslator ignores snake-cased properties [DATAREST-1276]

Open spring-projects-issues opened this issue 7 years ago • 5 comments

Édouard Hue opened DATAREST-1276 and commented

Given a @Document annotated class with the following attribute, and an according @RepositoryRestResource:

@Field
@JsonProperty("cooking_duration")
private Duration cookingDuration;

When issuing a GET request with ?sort=cooking_duration, the org.springframework.data.rest.webmvc.json.JacksonMappingAwareSortTranslator won't translate cooking_duration to cookingDuration and no sorting is performed.

When changing @JsonProperty("cooking_duration") to @JsonProperty("cooking-duration"), and doing a ?sort=cooking-duration request, JacksonMappingAwareSortTranslator properly resolves the property name.

It looks like org.springframework.data.rest.webmvc.json.JacksonMappingAwareSortTranslator.SortTranslator#SPLITTER is used to split the property name with _ and .. I can see the case for splitting on . for nested properties paths, but why would you split on underscores?


No further details from DATAREST-1276

spring-projects-issues avatar Aug 13 '18 16:08 spring-projects-issues

Any update on this one? Issue is still there in sdr-3.4.6 https://stackoverflow.com/questions/66829865/spring-data-rest-cannot-sort-by-localdatetime-field

It seems it has been around for a while? https://stackoverflow.com/questions/40746303/spring-data-rest-sorting-fields-with-underscores/40862101#40862101

kevvvvyp avatar Mar 31 '21 21:03 kevvvvyp

Bumped into this bug today in SDR-3.7.13

tgeens avatar Jul 25 '23 13:07 tgeens

Any idea when this will be fixed?

balta3 avatar Jan 09 '24 17:01 balta3

Same happening to me, any idea when this will be fixed?

italoborges avatar May 17 '24 13:05 italoborges

Does anyone have any updates on that?

wmrodrigues avatar May 17 '24 14:05 wmrodrigues