apache / apache/grails-intellij-plugin

Grails named query bug: 'parent' cannot be applied to '(groovy.lang.Closure)'

Open
#116 0 comments 0 reactions 0 assignees View on GitHub
bug imported-from-youtrack
Dominant language
Java
Stars
17
Forks
4
Avg merge
5d 15h
Merged PRs (30d)
4

Description

Support feedback:

I have found a bug in syntax check during the writing of domain model named query in Grails application.

Let's consider we have got the following model:
```
class Section {
long projId
hasMany = [
requirements: Requirement
]
}

class Requirement {
belongsTo = [ parent: Section ]

namedQuery = {
fetchByProjectId { projectId ->
parent {
eq 'projId', projectId
}
}
}
}
```
Query `fetchByProjectId` fetches all requirements which belong to specified project and works fine, but IDEA says that current syntax is incorrect and provides the following message: 'parent' cannot be applied to '(groovy.lang.Closure)'.

Note: if we try to move query to another side, so that entity which contains query has got 'hasMany' relation, than everything works fine. Syntax check fails only for 'belongsTo' relation.


OS: Windows 7
JDK: JDK 1.6.0
IDEA: 11.0
Build: IU-117.798

---

*Imported from [IDEA-91792](https://youtrack.jetbrains.com/issue/IDEA-91792) · Type: Bug · Votes: 1*
*Comments, attachments, dates and reporter are not part of the export — follow the link above for the full history.*

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the report in IntelliJ IDEA 11 with the Section and Requirement domain models and the fetchByProjectId named query shown here. Start by locating the Grails named-query syntax inspection and its handling of belongsTo associations; done means the parent closure is accepted without an error while the existing hasMany behavior remains valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.