Hi Murray, 2013/2/15 Murray Cumming <[email protected]>: > On Sun, 2012-05-20 at 17:44 +0200, Murray Cumming wrote: >> On Sun, 2012-05-20 at 17:39 +0200, Lukas Eder wrote: >> > After all, an org.jooq.Name type as I had suggested here would >> indeed >> > come in handy! :-) >> > https://groups.google.com/d/msg/jooq-user/SPq6lKX-BtM/Qyrly-JrjC0J >> > >> > I will implement #1431 in the next release 2.4.0: >> > https://sourceforge.net/apps/trac/jooq/ticket/1431 >> > >> > It will contain the following method, which can be used with various >> > plain SQL constructs: >> > Name Factory.name(String) >> >> Many thanks. >> >> I guess there will be some way to the get a string from that Name, for >> use when building a raw SQL query via string concatenation. > > I'm finally trying this, using code like this (with some checks): > > Name jooqName = Factory.name(name); > String[] nameParts = jooqName.getName(); > String escaped = nameParts[0]; > > However, I just get the same string that I passed into Factory.name(), > with no escaping.
Yes, these string literals are the raw data. In order to apply escaping, you have to "render" them as SQL. For instance: Name jooqName = Factory.name(name); new Factory(dialect).render(jooqName); See the relevant Javadoc here: http://www.jooq.org/javadoc/latest/org/jooq/impl/Factory.html#render(org.jooq.QueryPart) > Also, I would expect to have to mention the SQLDialect (or the > connection) somewhere, because the escaping would depend on the server > used. The SQLDialect is always available in the context of a "Configuration" (e.g. a Factory). jOOQ's QueryParts are dialect-independent. Some information about this can be found here (and in subsequent sections): http://www.jooq.org/doc/2.6/manual/sql-building/factory/ 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.
