2013/2/19 Lukas Eder <[email protected]>:
> 2013/2/19  <[email protected]>:
>> I maybe missing something but would it not be possible to handle this by
>> turning the original SQL select into a sub select so
>>
>>     select * from table
>>
>> ends up as
>>
>>     select count(*)
>>     from ( select * from table )
>>
>> This way all the edge cases caused by things like DISTINCT and UNION operate
>> correctly as long as the DB engine can handle them within a sub-select. It
>> also deals with the issue of DBs that do not have the window functions.
>>
>> I am saying this without any understanding of how you hold a query within
>> JOOQ so do not know if you can defind such a wrapping at will.
>
> I must've had tomatoes on my eyes. Trying to patch rendering and
> binding and all that... Sheesh ;-)
>
> This will indeed "get rid" of most of the corner cases, as it isn't
> really a complex query transformation. Here are some corner-cases that
> would persist:
>
> - The FOR UPDATE clauses. But that can be left as the user's
> responsibility, not to pass a SELECT .. FOR UPDATE to this new
> Executor.fetchCount(Select<?>)
>
> And here is a new corner-case:
>
> - "SELECT 1 FROM ..." Some databases cannot handle unnamed columns in
> subqueries. E.g. SQL Server can't run SELECT count(*) FROM (SELECT 1).
> It would have to be changed to SELECT count(*) FROM (SELECT 1 [dummy])

... of course, in most situations, users will want to avoid passing a
previously paged query to this new method. The COUNT(*) value should
probably be applied on an unpaged query, in order to calculate the
number of available pages... I guess that jOOQ shouldn't do any magic
here, and leave the query untouched in this case.

-- 
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/groups/opt_out.


Reply via email to