chore(cqn4sql): make it possible to use nice aliases again#1466
Open
patricebender wants to merge 5 commits intomainfrom
Open
chore(cqn4sql): make it possible to use nice aliases again#1466patricebender wants to merge 5 commits intomainfrom
patricebender wants to merge 5 commits intomainfrom
Conversation
A while back we introduced [technical aliases](#1082) (like `$B`, `$a`, etc.) to prevent ambiguities for some OData requests. However, sometimes it is nice to have readable aliases again, e.g., for presentations or debugging. Set the environment variable `USE_TECHNICAL_ALIAS=false` to get nice aliases again: ```js USE_TECHNICAL_ALIAS=false cds r --run . > cds.ql`SELECT author.name, genre.name from ${Books} where exists author[books.genre.name == 'Fantasy']`.toSQL().sql ``` ```diff --- a/query.sql +++ b/query.sql @@ -1,15 +1,15 @@ SELECT author.name as author_name, genre.name as genre_name -FROM sap_capire_bookshop_Books as Books - left JOIN sap_capire_bookshop_Authors as author ON author.ID = Books.author_ID - left JOIN sap_capire_bookshop_Genres as genre ON genre.ID = Books.genre_ID +FROM sap_capire_bookshop_Books as "$B" + left JOIN sap_capire_bookshop_Authors as author ON author.ID = "$B".author_ID + left JOIN sap_capire_bookshop_Genres as genre ON genre.ID = "$B".genre_ID WHERE exists ( SELECT 1 as "1" - FROM sap_capire_bookshop_Authors as author2 - inner JOIN sap_capire_bookshop_Books as books2 ON books2.author_ID = author2.ID - inner JOIN sap_capire_bookshop_Genres as genre2 ON genre2.ID = books2.genre_ID - WHERE author2.ID = Books.author_ID + FROM sap_capire_bookshop_Authors as "$a" + inner JOIN sap_capire_bookshop_Books as books ON books.author_ID = "$a".ID + inner JOIN sap_capire_bookshop_Genres as genre2 ON genre2.ID = books.genre_ID + WHERE "$a".ID = "$B".author_ID and genre2.name is 'Fantasy' ); ```
Contributor
|
This is really good for making the queries more readable 👍 It does not need to be used in production where there may be reasons for technical aliases, but especially for inspecting the SQL, it is quite helpful:
Maybe we could use |
Akatuoro
approved these changes
Feb 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

A while back we introduced technical aliases (like
$B,$a, etc.) to prevent ambiguities for some OData requests.However, sometimes it is nice to have readable aliases again, e.g., for presentations or debugging.
Set the environment variable
USE_TECHNICAL_ALIAS=falseto get nice aliases again: