Hello Christopher,

> First let me say that I adore this project. Finding new wanted or unexpected
> features in jOOQ has been making my day all week.

Thanks for the feedback. Glad you have liked it so far!

> The partition and the outer join would both be nice to wrap. It would be
> great if I could specify a maximum line length of something like 60
> characters. Did I overlook this setting, or is this a new feature request?

The current formatting is quite simple. Adding things like a maximum
line length seems to be quite a challenge requiring some more thinking
about general SQL formatting strategies. In fact, to generally improve
formatting, it might be wise to express formatting events more
semantically, such as:

- subquery-start / subquery-end
- field-list-start / field-list-end
- window-clause-start / window-keyword / ...

I'll have a closer look at these things to see what can be done. I
have added feature request #1872 for this
https://github.com/jOOQ/jOOQ/issues/1872
.
> Side note: The documentation does not delve deeply enough into logging and
> settings for my liking. I didn't even know that pretty-printing queries was
> possible until I started digging through the API. It's a great feature, and
> you ought to promote it.

I agree, this could be better documented. I will do this for the next
version of jOOQ:
https://github.com/jOOQ/jOOQ/issues/1871

Thanks also for your contribution

Cheers
Lukas

2012/10/19 Christopher Martin <[email protected]>:
> First let me say that I adore this project. Finding new wanted or unexpected
> features in jOOQ has been making my day all week.
>
> Our database team is particularly concerned with logging, and they want to
> make sure that every query and procedure call gets logged, with its
> parameters, in a readable format. The SQL renderer is probably a pretty
> boring piece of software to work on, but quality of logging output is going
> to be a crucial part of getting my organization to adopt jOOQ.
>
> Jooq's rendering, for the most part, is an improvement over our hand-written
> queries, but I anticipate getting a little pushback on line length. It can
> get bad in our system because we tend to have long identifiers and need to
> fully qualify tables with the schema name. Here's an example (identifiers
> are redacted, but their lengths are accurate):
>
> select
>   alpha_id,
>   alpha_date
> from (select
>         alpha_id,
>         alpha_date
>       from (select
>               zzzzzzzz.xxxxxxxxxxxxxxxxxxxx.yyyyyyyyyyyyy alpha_id,
>               zzzzzzzz.xxxxxxxxxxxxxxxxxxxx.ssssssssss alpha_date,
>               row_number() over (partition by
> zzzzzzzz.xxxxxxxxxxxxxxxxxxxx.pppppp order by
> zzzzzzzz.xxxxxxxxxxxxxxxxxxxx.ssssssssss desc) r
>             from zzzzzzzz.xxxxxxxxxxxxxxxxxxxx)
>       where R = 1) alpha
> left outer join zzzzzzzz.qqqqqqqqqqqqqqqqqqqqqqq on
> zzzzzzzz.qqqqqqqqqqqqqqqqqqqqqqq.yyyyyyyyyyyyy = alpha_id
> where zzzzzzzz.qqqqqqqqqqqqqqqqqqqqqqq.yyyyyyyyyyyyy is null
>
> The partition and the outer join would both be nice to wrap. It would be
> great if I could specify a maximum line length of something like 60
> characters. Did I overlook this setting, or is this a new feature request?
>
> Side note: The documentation does not delve deeply enough into logging and
> settings for my liking. I didn't even know that pretty-printing queries was
> possible until I started digging through the API. It's a great feature, and
> you ought to promote it.
>
> If there is any request I have of the documentation, it's even more
> examples! Perhaps my use case might be a useful one? My short code is given
> below.
>
> class JooqLogging extends DefaultExecuteListener {
>     private static final Logger log = getLogger(JooqLogging.class);
>     public void end(ExecuteContext ctx) {
>         if (log.isDebugEnabled()) {
>             Factory factory = new Factory(ctx.getDialect(), new
> JooqSettings());
>             if (ctx.query() != null) {
>                 log.debug(factory.renderInlined(ctx.query()));
>             } else if (ctx.routine() != null) {
>                 log.debug(factory.renderInlined(ctx.routine()));
>             } else if (!StringUtils.isBlank(ctx.sql())) {
>                 log.debug(ctx.sql());
>             }
>         }
>     }
> }
>
> class JooqSettings extends Settings {
>     {
>         setExecuteLogging(false);
>         getExecuteListeners().add(JooqLogging.class.getName());
>         setRenderNameStyle(RenderNameStyle.LOWER);
>         renderFormatted = true;
>     }
> }

Reply via email to