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

Allow null overrideAlias in query functions #1838

Open
Swahvay opened this issue Nov 8, 2024 · 2 comments
Open

Allow null overrideAlias in query functions #1838

Swahvay opened this issue Nov 8, 2024 · 2 comments

Comments

@Swahvay
Copy link
Contributor

Swahvay commented Nov 8, 2024

There is currently no way to remove an alias with aliasOverride in simpleClause. This is useful in cases where I do some augmenting on the field name like query.eq('LOWER(name)', $name). If I am using this clause in a CustomClauseQuery that joins with another table and has specified an alias, there is no way to remove that alias for this clause. It ends up compiling to alias.LOWER(name) = $1. I can get around this by specifying fieldAlias in loadEntOptions and then manually setting the tableName to 'table_name alias'. Kinda hacky but technically works fine.

I'm suggesting changing the overrideAlias definition from overrideAlias?: string to overrideAlias?: string | null. The other solution I thought of was something like a new parameter that would wrap column names. So it would be something like query.Eq('name', $name, { columnOp: 'LOWER' }).

@lolopinto
Copy link
Owner

makes sense. just to jog my brain, how does LOWER(name) know which table to use?

@Swahvay
Copy link
Contributor Author

Swahvay commented Nov 10, 2024

In this example name is just the column name, so if you were using an alias you would have to do LOWER(alias.name).

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

No branches or pull requests

2 participants