apache / apache/grails-core

Dynamic finders with InList and OrderBy issue

Open
#14,605 4 comments 0 reactions 0 assignees View on GitHub
relates-to: gorm
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

This is being submitted as a bug because it should either report an error or work. Instead it silently ignores the OrderByPath suffix

### Steps to Reproduce

1. Using a normal grails domain object with postgres 5.x, include both Inlist and OrderBy
`def allLocations = Location.findAllByIdInListOrderByPath(locationArray)`
2. Enable show_sql in application.yml
```
hibernate:
...
show_sql: true
logSql: true
```
3. Check log output for 'order by' in generated SQL

### Expected Behaviour

Hibernate SQL should have an 'order by' clause or it should generate an exception if invalid (not sure if OrderBy is supported for InList).

### Actual Behaviour

OrderBy is ignored

### Environment Information

- **Operating System**: Linux and Windows 7
- **Grails Version:** 3.2.9
compile 'org.grails.plugins:postgresql-extensions:5.0.0'
compile "org.grails.plugins:hibernate5"
compile "org.hibernate:hibernate-core:5.1.6.Final"
compile "org.hibernate:hibernate-ehcache:5.1.6.Final"
- **JDK Version:** 1.8
- **Container Version (If Applicable):** N/A

Contributor guide

Open the contributing guide

Research direction

Reproduce Location.findAllByIdInListOrderByPath with show_sql and inspect the generated SQL. Compare the dynamic finder parsing and query construction for InList and OrderBy; done means the query includes the expected order by clause or rejects the unsupported combination with a clear error.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy, postgres
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.