Skip to content
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 SPI to auto-alias top level projections #11545

Open
lukaseder opened this issue Mar 1, 2021 · 2 comments
Open

Add SPI to auto-alias top level projections #11545

lukaseder opened this issue Mar 1, 2021 · 2 comments

Comments

@lukaseder
Copy link
Member

lukaseder commented Mar 1, 2021

An occasionally re-occurring request is to be able to auto-alias top level projections for a variety of reasons, including:

  • Standardising output for some third party to consume
  • Migrate legacy SQL statements to a new scheme, where such projections might be useful
  • Accommodating the needs of a third party mapping library

An example would be:

SELECT 
  t1.col1 AS t1_col1,
  t1.col2 AS t1_col2,
  t2.col3 AS t2_col3
FROM t1, t2

So, the naming scheme would automatically concatenate table_column. Or also schema_table_column. Or schema_table_column_attribute. Or involve abbreviations from a lookub, e.g. tabl_column (where TABL is a standardised 4 character abbreviation for TABLE, just like ACCO would be the one for ACCOUNT. I've blogged about this approach here: https://blog.jooq.org/a-guide-to-sql-naming-conventions/).

The use case is probably not the most popular, but when it arises, jOOQ could add a lot of value here, because doing this manually is way too tedious and doing it with a utility on a per-query basis is still a bit error prone (it could be forgotten, users don't think of all the edge cases, e.g. when using aliases in ORDER BY, etc.)

Let's collect feedback about this requirement and see what we can offer here.

@lukaseder
Copy link
Member Author

Any SPI implementation will probably need at least these contexts:

  • The Field, obviously
  • The field index in the Select
  • The Select
  • The Context, perhaps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant