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 alias support for filterMany #3452

Open
artemik opened this issue Aug 10, 2024 · 0 comments
Open

Add alias support for filterMany #3452

artemik opened this issue Aug 10, 2024 · 0 comments

Comments

@artemik
Copy link

artemik commented Aug 10, 2024

Expected behavior

I need to execute a query where filterMany requires using an alias to support a subquery using max(...) function.

Example:

return new QOrder()
                .items.filterMany(new QItem()
                        .alias("iii")
                        .startDate.eq(new QItem()
                                .select("max(startDate)")
                                .raw("order = iii.order_id")
                                .query()
                        )
                        .getExpressionList())
                .findList();

Actual behavior

It currently fails with something like table "iii" is missing from FROM. Probably because getExpressionList() doesn't forward aliases. Query log also proves there was no alias generated for the query.

For the above query exactly, the workaround seems to give an alias to the parent query instead and rewrite the query a bit:

return new QOrder()
                .alias("ooo")
                .items.filterMany(new QItem()
                        .startDate.eq(new QItem()
                                .select("max(startDate)")
                                .raw("order = ooo.id")
                                .query()
                        )
                        .getExpressionList())
                .findList();

This basically seems to have the same result, but I'm not sure if it would cover all cases? So opening that issue to hear thoughts.

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

1 participant