Thank you for your precisions ! It is good to know that the query parts I want to catch are actually org.jooq.Table.
Cheers, Aurélien On Thursday, December 5, 2013 11:48:29 AM UTC+1, Lukas Eder wrote: > > Hi Aurélien, > > Good question(s) :-) > It's clear that the VisitListener SPI will need lots of documentation. Its > current state is "experimental". Although I don't expect significant > changes to the contracts, there might be some helpers added in future > releases, to make interaction simpler. AST transformation is not a trivial > problem in any language. > > Anyway, the feedback from your experiments will be highly valuable to this > group. So thanks in advance for doing this :-) > > Further comments inline: > > 2013/12/3 Aurélien Manteaux <[email protected] <javascript:>> > >> Hi Lukas, >> >> I need a confirmation to be sure I am not going in the wrong direction. >> >> In order to get all the tables referenced in a query (from, sub query >> from, inner join, outer join, other join ?), I do : >> - in the configuration, I combine a VisitListenerProvider to the >> VisitListenerProvider[], >> - my VisitListenerProvider returns a custom VisitListener, >> - the custom VisitListener uses only visitStart() (I had to choose one of >> the 4 methods :), >> - in visitStart(), if context.clause() equals Clause.TABLE_REFERENCE, >> context.queryPart() is added to the query tables set. >> > > This looks good to me. Beware that you will not capture plain SQL tables > and CustomTables like this, though. For this, you'd also have to listen to > Clause.TEMPLATE (plain SQL) and Clause.CUSTOM (CustomTables), and then do a > type-check: > > (context.queryPart() instanceof org.jooq.Table) > > >> Does the condition "if context.clause() equals Clause.TABLE_REFERENCE" >> returns true only and for all the tables referenced in a query ? >> > > Tables in general are identified by Clause.TABLE. Physical table > references are identified by Clause.TABLE_REFERENCE (excluding, for > instance, derived tables). So, yes, that's the right clause for your > purpose. > > >> It works fine on "SELECT a,b,c FROM table WHERE d=e" or on "SELECT a,b,c >> FROM table1 t1 JOIN table2 t2 ON t1.a=t2.a WHERE d=e", but : >> - will it always work ? (cf org.jooq.Clause : "Disclaimer, This SPI is >> still experimental!") >> > > I can informally guarantee (whatever that means) that there is no > intention of changing this semantics of Clause.TABLE_REFERENCE again. But > as this is an experimental SPI, there may be quite a few edge-cases that > are not yet properly covered. So you will run a slight risk by implementing > this SPI. > > Rest assured that all potential incompatible changes to this SPI will be > clearly indicated in the release notes and only performed between minor > releases, not patch releases. We'll try to keep incompatible changes at a > minimum and stick with semantic versioning whenever possible. > > >> - will it still works in all other cases where tables are referenced ? >> > > If by "other cases" you mean UPDATE, INSERT statements, etc, then yes, > that's the intention. > > 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.
