jOOQ
jOOQ copied to clipboard
Cannot use Table as SelectField from derived table where nesting records isn't supported natively
https://github.com/jOOQ/jOOQ/issues/13843 addresses an issue where this query:
val subquery = context.select(EXAMPLE_TABLE).from(EXAMPLE_TABLE)
context.selectFrom(subquery).execute()
Produces illegal SQL in PostgreSQL, e.g.
SELECT alias_118559696.example_table
FROM (
SELECT cast (ROW (example_table.*) AS example_table)
FROM example_table
) AS alias_118559696
It should produce:
SELECT alias_118559696.example_table
FROM (
SELECT cast (ROW (example_table.*) AS example_table) AS example_table
FROM example_table
) AS alias_118559696
The fix from #13843 was not applied to dialects that have no native support for nesting reocrds. This issue should address that.
It's harder in other dialects, which tend to resort to 2 kinds of emulations:
- flatten out nested record definitions (can't alias that with a single alias)
- resort to the
MULTISETemulation (can't use that in some embeddable edge cases)