Grails
  1. Grails
  2. GRAILS-2511

Support ranges in find 'between' calls

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0.1
    • Fix Version/s: None
    • Component/s: Persistence
    • Labels:
      None

      Description

      It would be great if find methods accepted a range when using the between clause, not just only two parameters.
      Ranges are used in other parts of Grails to represent these kind of constraints.

      def now = new Date()
      Book.findAllByPublishedDateBetween( now -7, now )
      Book.findAllByPublishedDateBetween( [(now -7)..now] )
      

        Activity

        Hide
        Graeme Rocher added a comment -

        There is no scope / time to resolve these remaining lower priority issues for 1.2 so moving to 1.3

        for 1.2 final only issues considered blocking will now be fixed

        Show
        Graeme Rocher added a comment - There is no scope / time to resolve these remaining lower priority issues for 1.2 so moving to 1.3 for 1.2 final only issues considered blocking will now be fixed
        Hide
        Jeff Scott Brown added a comment -

        'Between' may not be the right word. 'In' or 'InRange' might be better. Thoughts?

        Show
        Jeff Scott Brown added a comment - 'Between' may not be the right word. 'In' or 'InRange' might be better. Thoughts?
        Hide
        Tim Yates added a comment -

        I think this is already covered by:

        Book.findAllByPublishedDateInRange( (now -7)..now )
        

        However, the InRange finder doesn't seem to appear in the documentation, so is tricky to 'find'

        https://github.com/SpringSource/grails-data-mapping/blob/master/grails-datastore-gorm-hibernate4/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/metaclass/AbstractClausedStaticPersistentMethod.java#L320

        Show
        Tim Yates added a comment - I think this is already covered by: Book.findAllByPublishedDateInRange( (now -7)..now ) However, the InRange finder doesn't seem to appear in the documentation, so is tricky to 'find' https://github.com/SpringSource/grails-data-mapping/blob/master/grails-datastore-gorm-hibernate4/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/metaclass/AbstractClausedStaticPersistentMethod.java#L320
        Hide
        Tim Yates added a comment -

        https://github.com/grails/grails-doc/pull/164/files

        Not sure if it's good enough, but it's a start

        NB: Posted them half way down the list, so the sentence following the list still holds true

        Show
        Tim Yates added a comment - https://github.com/grails/grails-doc/pull/164/files Not sure if it's good enough, but it's a start NB: Posted them half way down the list, so the sentence following the list still holds true
        Hide
        Andres Almiray added a comment -

        I think this issue can be closed given that https://github.com/grails/grails-doc/pull/164 has been merged by Graeme

        Show
        Andres Almiray added a comment - I think this issue can be closed given that https://github.com/grails/grails-doc/pull/164 has been merged by Graeme
        Hide
        Graeme Rocher added a comment -

        I can't remember when InRange was added, but I think it was a long time ago, so closing without fixed version

        Show
        Graeme Rocher added a comment - I can't remember when InRange was added, but I think it was a long time ago, so closing without fixed version

          People

          • Assignee:
            Jeff Scott Brown
            Reporter:
            Andres Almiray
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Last Reviewed:

              Development