Details
-
Type:
Improvement
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 2.0-RC2
-
Fix Version/s: 2.3-M2
-
Component/s: None
-
Labels:None
Description
If you assign a Where query to an untyped variable like so:
def authors = Author.where { age > avg(age) }
then the authors variable is given an explicit type of DetachedCriteria by the underlying AST transform. This results in class cast errors if you do things like:
authors = "Some text"
This is very strange for users since the code is perfectly valid Groovy, it's just the AST transformation is having unintended side-effects.
See GRAILS-8355 for background and sample app.
Issue Links
- is related to
-
GRAILS-8355
Multiple property projections not working with Where queries
-
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits
It is unlikely we'll able to allow re-assignment, the best we can do is fail with a compilation error if re-assignment is attempted. We need to know that a variable is a DetachedCriteria in case the where method is used on the variable in query chaining