>> In the short run, however, short of having Cloneable models...
>
> Ah, that was the crucial piece of information that I was missing: You can't
> easily clone the model.

Unfortunately, no. Of course, you can always clone QueryParts by
serialising / deserialising them, but that seems a bit over the top.

> I thought you could because all other parts of jOOQ
> I looked at can do this.

Hmm, none of them are Cloneable. What did you have in mind?

> So another approach would be to add
>
> int Query.fetchCount()
>
> to the API. The implementation should build SQL which ignores anything
> between "select" and "from". The implementation of this would be in the
> dialect.

I guess I could live with such a solution. It would have to be put on
org.jooq.Select, though, not on Query/ResultQuery. The latter could
wrap plain SQL queries or non-SELECT queries, where patching the
projection doesn't make sense.

And also, Factory.fetchCount(Select<?>) could be useful. In that
event, jOOQ's internals could take care of not rendering the
projection and avoiding variable binding originating from the
projection.

> I'm not sure if that always gives the same results when you use grouping and
> similar things, though. Maybe you can throw an error when the SQL contains
> dangerous elements.

There are still open questions. The projection has an implicit effect
on the table expression in many cases, e.g.:

- When the DISTINCT keyword is applied
- When UNIONs are involved
- When Oracle PIVOT tables are used
- When some sorts of Oracle hints are applied
- When ORDER BY clauses reference column indexes from the projection
- When CUBRID / Sybase window function ORDER BY clauses reference
column indexes from the projection
- When paging is applied and simulated with ROW_NUMBER() calculations
- When paging is applied with the TOP clause

Maybe it would be sufficient to document this in the Javadoc... I'll
register #2200 for this:
https://github.com/jOOQ/jOOQ/issues/2200

Thanks for sharing your ideas.

Cheers
Lukas

-- 
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