--
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 jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/129508a9-e951-4c0d-b114-f4bb19e027f4%40googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "jOOQ User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jooq-user/VKee0sUdG-w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/CAB4ELO6hBSsKKL%2BFj39dDnPiKPSrPCB43-hK2htNRdQLevOEpQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/C91B8EF1-DC30-423F-B029-9DDC36BF496D%40conexus.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/CAB4ELO5KrHZ0CkSMNXTO9EeZ1297bvAhs7vczMkezF%2BeDtyMng%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/E4E4ADCB-4574-4DEB-9236-3FAA2BF546F2%40conexus.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/CAB4ELO5UVC-b_2YQzDyWuaNSC_-aSWsnKvAMR5%3DrR_MV5-txRQ%40mail.gmail.com.
Thanks! That’s working but now I have a dilemma about VisitListener. In particular, Clause is deprecated, but I’m not sure how to dispatch based on the type of QueryPart alone, especially since most implementing classes are not visible. For example, suppose I just parsed “SELECT * FROM …” or “SELECT A FROM …” into a QueryPart, and now I want to do something different when I encounter an org.jooq.impl.AsteriskImpl than when I encounter an org.jooq.impl.FieldAlias. Can I do that without using Clause? How do I actually access the data inside the Impl classes (e.g., get the list of field names), if the Impl classes are not visible? My current solution to this problem is to print the SQL into H2, and then use H2’s parser to parse into H2’s abstract syntax classes, and then manipulate those, but I’m hoping there’s a way to avoid H2 when processing queries (just like there is when processing meta data) - my use case is JOOQ as ‘abstract syntax for the relational algebra fragment common to most SQL vendors’.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/AF072D37-6381-466B-AF7F-FE3BF4B01F82%40conexus.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/CAB4ELO5vJyoF45nxwji5gWcoVcyJ2dQKfFtesHA-6KBz0Emp%2BA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/3E207FCD-37FC-40FC-AD83-F09784E4C9E4%40conexus.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/CBD9407A-3899-4CDC-950B-14FF72051901%40conexus.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/CAB4ELO5JxkReXL57Sqf5Le3zqB0KdbpxDWr%3DCgm%3DGV0bXr60jA%40mail.gmail.com.
Thanks again! I’m still making progress with my use case and had a few more quick questions: when emitting SQL code, is there a way to force:- implicit type coercions to made explicit? i.e., “1” = 1 ~~~> cast “1” as integer = 1
- "select *" to emit as the named expressions? I.e., select * ~~~> select x.y as z, p.q as r …
- “from" to name every column? i.e., from A, B ~~~> from A as a, B.b as b
- “where” to qualify every field reference? i.e., where A = B ~~~> a.A = b.B
- “join" syntax into select/from/where syntax
On Jun 22, 2020, at 9:54 AM, Lukas Eder <lukas...@gmail.com> wrote:Hi Ryan,Thanks for your message.I'm assuming you're still using the parser and try to transform the generated SQL in jOOQ. You'll have to find a way to detect the cases that you've mentioned below, but once you do, I think all is possible:On Mon, Jun 22, 2020 at 6:31 PM Ryan Wisnesky <ry...@conexus.com> wrote:Thanks again! I’m still making progress with my use case and had a few more quick questions: when emitting SQL code, is there a way to force:- implicit type coercions to made explicit? i.e., “1” = 1 ~~~> cast “1” as integer = 1Use Field.cast(DataType) or DSL.cast(Field, DataType), they're equivalent
- "select *" to emit as the named expressions? I.e., select * ~~~> select x.y as z, p.q as r …It depends on much you insist on precisely this transformation. The simplest transformation would be to just wrap the query in a derived table and work with Select.getSelect().
- “from" to name every column? i.e., from A, B ~~~> from A as a, B.b as bI'm not sure what this means
- “where” to qualify every field reference? i.e., where A = B ~~~> a.A = b.BThe parser does this if you enable Settings.parseWithMetaLookups (you will have to provide jOOQ with some Meta data source via Configuration.set(MetaProvider)). But when the parser does this, it doesn't transform the SQL currently to produce qualified identifiers in the output.What's the use case of this transformation?
- “join" syntax into select/from/where syntaxYou can do this via: https://www.jooq.org/doc/3.13/manual/sql-building/queryparts/sql-transformation/ansi-join-to-table-lists/In the future, we'll implement quite a few such SQL transformations out of the box:I will create a few issues for the ones you've mentioned here, I think they could be quite useful for others. If you have more such use-cases, I'd love to hear about them!
Lukas
--
You received this message because you are subscribed to a topic in the Google Groups "jOOQ User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jooq-user/VKee0sUdG-w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/CAB4ELO6Gzmb2zdxY%2BWn3-9LrBMPNBDqO1c5zxqi3zPUD1QdFAw%40mail.gmail.com.
What's the use case of this transformation?I’m trying to use JOOQ as a “universal parser” for a very simple select/from/where fragment of SQL with a simple abstract syntax, but across a bunch of vendors at once. But perhaps this is the same problem as the problem above - how to insert new variables in from clauses.
--
You received this message because you are subscribed to a topic in the Google Groups "jOOQ User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jooq-user/VKee0sUdG-w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/CAB4ELO6xsCzem48B0FkXoR%3D8KL41drZBf1sN_PiGjvyL9DKFhQ%40mail.gmail.com.
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 jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/86158B01-29C1-47FF-A100-77F91EF40D6F%40conexus.com.