-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Settings.renderAutoAliasedDerivedTableExpressions to auto alias unnamed field expressions in derived tables #579
Comments
A thorough fix is best implemented when we have immutable queries, i.e. queries where we can no longer add columns to the Select<?> select =
create().select()
.from(create().selectOne());
Field<?> field = select.field(0); The above |
This issue also cropped up in #1699 when testing the DB2 support. |
Looking into this now.
Since this is a delicate change with regression risks, I'm not going to backport the fix. |
A new marker interface is necessary to denote all the
|
Some extensive test will be necessary for all
|
More candidates:
Cases where a wrapper type should delegate to the contained type (similar to
In principle, there's also room for making this dialect specific, e.g. |
Very cool! This query: ctx.selectFrom(select(T_BOOK.ID, inline(1), trueCondition()).from(T_BOOK)) Now renders this SQL: select "alias_77757314"."id", "alias_77757314"."1", "alias_77757314".condition
from (
select
"public"."t_book"."id",
1 as "1",
true as condition
from "public"."t_book"
) as "alias_77757314" As can be seen, there are likely many select *
from (
select
true,
false,
1
) as t Produces:
It's unclear if this only causes issues with the asterisk, currently, because it's not really possible to dereference any columns from t |
Another regression risk, our insert into `test`.`t_author` (`ID`, `LAST_NAME`)
values (
(
select *
from (
select (max(`test`.`t_author`.`ID`) + 1) as add
from `test`.`t_author`
) as `t`
),
'X'
) The error is now:
This works: insert into `test`.`t_author` (`ID`, `LAST_NAME`)
values (
(
select *
from (
select (max(`test`.`t_author`.`ID`) + 1) as `add`
from `test`.`t_author`
) as `t`
),
'X'
); |
Continuing this, I feel there are many risks of introducing this as a new default behaviour, especially when asterisks are involved, i.e. when name resolution in the RDBMS is not being done. For example, the following transformations are now made: -- Before
select * from t, (select 1) u
-- After
select * from t, (select 1 "1") u But depending on other settings (e.g. quoting of identifiers), If, however, we introduce this as an opt-in behaviour, guarded by a flag called
|
The 3 state setting might be useful in the future, when we do this also at the top level to guarantee field names (I think there's already an issue for this). Implemented in jOOQ 3.20 |
Like SimpleCheckQueryPart for SimpleQueryPart, a new NamedCheckField for NamedField contents has been added for cases like Coerce, which are wrappers for something that could be a NamedField.
Worth looking into the SPI for auto alias generation as well: |
This will produce a syntax error:
Workaround:
See also:
array_agg
in a subqueryThe text was updated successfully, but these errors were encountered: