Skip to content

Conversation

aleclarson
Copy link

Add SQL.Aliased#as(alias) method, allowing you to alias a subquery column.

When using db.$with().as(), a subquery is returned, whose columns may be a SQL.Aliased instance. If you want to reference a subquery's column in another subquery, but use a different column name, this PR will make it easier to do that.

Current workaround

The drawback of this workaround is it doesn't automatically inherit the type from the referenced column, so you have to manually specify it, which is fragile.

sql<string>`${subquery.foo}`.as('alias')

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

Successfully merging this pull request may close these issues.

1 participant