2014-02-18 19:42 GMT+01:00 Ben Hood <[email protected]>:

> Hey Lukas,
>
> On Tue, Feb 18, 2014 at 6:07 PM, Lukas Eder <[email protected]> wrote:
> > 1. A VisitListener that replaces a top-level Field QueryPart in the
> > Clause.SELECT clause when some condition is matched. An example can be
> seen
> > here:
> >
> http://www.jooq.org/doc/latest/manual/sql-building/queryparts/custom-sql-transformation/transformation-bind-value-abbreviation/
>
> This style of visitor API does lend itself well to being able to defer
> the logic of SQL rewriting to the app but still have access to JOOQ's
> type safety and column metadata. So had I been a bit more mature, I
> would have considered this approach. That said, I at the start of the
> day, I didn't know about this API. Would it let you patch out only the
> columns of the outer most select?
>

Yes, it would. The linked manual page also does this (note the call to
queryPartsLength() == 1):

    @Override
    public void visitEnd(VisitContext context) {

        // If any abbreviations were performed before...
        if (anyAbbreviations) {

            // ... and if this is the top-level QueryPart, then append
a SQL comment to indicate the abbreviation
            if (context.queryPartsLength() == 1) {
                context.renderContext().sql(" -- Bind values may have
been abbreviated");
            }
        }
    }



> > 2. An ExecuteListener that patches generated SQL using a regex. This
> might
> > be more difficult (not possible) to get right, generally.
>
> This sounds like a feat of Jedi framework building.
>

;-)
http://geek-and-poke.com/geekandpoke/2013/12/3/yesterdays-regex


> > 3. Your solution works fine, too, of course.
>
> If I had to specify the API based on this problem alone, it would be a
> callback filter on the SelectJoinStep. But maybe that just boils down
> to option (1) in the end.


Yes, if you want more sophistication, you'll probably wind up with option
(1)

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