Grails
  1. Grails
  2. GRAILS-8351

Improve error message for properties of relations in aggregate functions (Where queries)

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-RC1
    • Fix Version/s: 2.0-RC2
    • Component/s: None
    • Labels:
      None

      Description

      Given the query

      Book.where { author.age > avg(author.age) }
      

      Grails currently spits out the compilation error

      Cannot use aggregate function avg on property "null" - no such property on class org.example.Author exists
      

      This is no way indicates that you can't use relations in aggregate functions. It just looks like a bug in Grails. The error message either needs improving or relations' properties should be allowed in aggregate functions.

      You can use the project attached to GRAILS-8344 for testing. Simply modify the Where query used in BookController.test().

        Activity

        Show
        Graeme Rocher added a comment - Fixed by https://github.com/SpringSource/grails-data-mapping/commit/89b857377d9d56a634eb270a474dc252ff48554a

          People

          • Assignee:
            Graeme Rocher
            Reporter:
            Peter Ledbrook
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development