Hi Andrey,

Thanks for reporting! I bet there was some historic reason for the current
behaviour where offsets are ignored when offset-less limit calls are made.
I can't think of a good reason to maintain this legacy, so we'll fix this.

Indeed, we should also officially support reversing offset / limit calls.
Currently, this is not allowed through the Java API, but I can see that
this doesn't really matter to you when you're working with Clojure, as the
backing implementation SelectImpl doesn't care about the order of calls as
exposed by the DSL API.

I have registered a feature request for this:
https://github.com/jOOQ/jOOQ/issues/4784

2015-12-08 10:03 GMT+01:00 Andrey Antukh <[email protected]>:

> Hi Lukas.
>
> We found an strange behavior on the jOOQ query builder related to limit
> and offset order of application. Happens that if we have this query
> expression:
>
> somequery.offset(100).limit(10)
>
> the offset is just ignored. And I'm pretty sure (viewing the jOOQ code)
> that it is always ignored if it is used before limit:
>
>     @Override
>     public final SelectImpl offset(int offset) {
>         if (limit != null) {
>             getQuery().addLimit(offset, limit);
>         }
>         else if (limitParam != null) {
>             getQuery().addLimit(offset, limitParam);
>         }
>         return this;
>     }
>
> I know, this seems to be documented as expected behavior but in practice
> is very unexpected, because in SQL, limit and offset can be interchanged
> the order without any problem:
>
> test=# select x from generate_series(1,100) as x offset 10 limit 2;
>  x
> ----
>  11
>  12
>
> Thanks!
>
> Andrey
>
> --
> Andrey Antukh - Андрей Антух - <[email protected]>
> http://www.niwi.nz
> https://github.com/niwinz
>
> --
> You received this message because you are subscribed to the Google Groups
> "jOOQ User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to