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

Alias-aware expr() support #2405

Closed
parisholley opened this issue Nov 11, 2021 · 2 comments
Closed

Alias-aware expr() support #2405

parisholley opened this issue Nov 11, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@parisholley
Copy link
Contributor

Is your feature request related to a problem? Please describe.

When using expr, unless you have a single table find() or a query builder with an alias, you can hit ambiguous column errors due to the lack of column prefixing. Eg: self-referential eager joins

Describe the solution you'd like
Expand expr to support passing a function like so:

expr((alias) => `lower(${alias}.column)`)

alternatively, perhaps we can add the ability to define the alias within find methods

@parisholley parisholley added the enhancement New feature or request label Nov 11, 2021
@B4nan
Copy link
Member

B4nan commented Nov 11, 2021

How do you expect that to work? expr is just an identity function, it needs to return string as it will be used as an object key. It also does not have any context so it would have to use global one?

Maybe we could instead have some known substring we would replace, maybe something like [::alias::] or even ${alias} as an escaped string. In the end we could use it automatically if we see a function in the argument.

@parisholley
Copy link
Contributor Author

substring would be sufficient

@B4nan B4nan closed this as completed in 48702c7 Nov 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants