Grails
  1. Grails
  2. GRAILS-9432 Miscellaneous Where query problems
  3. GRAILS-8366

year() function not allowed in the RHS of an expression in where queries

    Details

    • Type: Sub-task Sub-task
    • Status: In Progress
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      2.0.0.BUILD-SNAPSHOT

      Description

      Use the sample app from GRAILS-8344 as a base again. This time I'm having issues with the queries:

      def authors = Book.where { author.age > year(publishDate) }
      

      ,

      def now = new Date()
      def authors = Book.where { author.age > year(now) }
      

      and

      def now = new Date()
      def authors = Author.where { books.size() > year(now) }
      

      I would only class the error from the first example as an actual bug, but the others could do with more meaningful error messages.

        Activity

        Hide
        Peter Ledbrook added a comment -

        I'm also getting an odd message from this code:

        ...
           def authors = Author.where { books.size() > process(age) }
        ...
        
        private process(arg) {
            return arg
        }
        

        Something like:

        No signature of method: grails.gorm.DetachedCriteria.sizeGt() is applicable for argument types: (java.lang.String, grails.gorm.DetachedCriteria) values: [books, grails.gorm.DetachedCriteria@2bb04fbf] Possible solutions: sizeGt(java.lang.String, int), sizeGe(java.lang.String, int), sizeLt(java.lang.String, int), sizeEq(java.lang.String, int), sizeLe(java.lang.String, int), sizeNe(java.lang.String, int)
        
        Show
        Peter Ledbrook added a comment - I'm also getting an odd message from this code: ... def authors = Author.where { books.size() > process(age) } ... private process(arg) { return arg } Something like: No signature of method: grails.gorm.DetachedCriteria.sizeGt() is applicable for argument types: (java.lang.String, grails.gorm.DetachedCriteria) values: [books, grails.gorm.DetachedCriteria@2bb04fbf] Possible solutions: sizeGt(java.lang.String, int), sizeGe(java.lang.String, int), sizeLt(java.lang.String, int), sizeEq(java.lang.String, int), sizeLe(java.lang.String, int), sizeNe(java.lang.String, int)
        Hide
        Graeme Rocher added a comment -

        functions are only allowed on the LHS of expressions at the moment. Added a better compilation message. I'm looking at the last comment now.

        Show
        Graeme Rocher added a comment - functions are only allowed on the LHS of expressions at the moment. Added a better compilation message. I'm looking at the last comment now.

          People

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

            Dates

            • Created:
              Updated:
              Last Reviewed:

              Development