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

Bug: fetch and where with formula join will produce incorrect joins #2773

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

AlexWagner
Copy link
Contributor

When using a fetch and where on a formula joined field (maybe others are also affected) in a query,
the joins are build incorrectly.
The table alias is wrong, if you have a where clause with 3 path components and a fetch with 2.

See test case with childPerson -> parentPerson -> effectiveBean

The problem is somewhere located here:
https://github.com/ebean-orm/ebean/blob/master/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeBuilder.java#L680

"where" generates an extra join which is effectivly added to the root bean und not to the already existing child (from the select/fetch)

@AlexWagner AlexWagner changed the title Bug fetch and where formula join Bug fetch and where with formula join will produce incorrect joins Aug 3, 2022
@AlexWagner AlexWagner changed the title Bug fetch and where with formula join will produce incorrect joins Bug: fetch and where with formula join will produce incorrect joins Aug 3, 2022
@AlexWagner
Copy link
Contributor Author

@rbygrave any ideas on this?

@rbygrave
Copy link
Member

Sorry, I've been focused on the enhancement stuff. Looking to get a release out and then I hope to get some time to look at this.

@rbygrave
Copy link
Member

I feel that we really need a logical version of @Formula based on paths that determines the joins using the normal orm mechanism. That is, I see @Formula as really @SqlFormula and the fixed joins are problematic (once a formula is on a cardinality ToMany path it should be LEFT JOIN etc).

rPraml added a commit to FOCONIS/ebean that referenced this pull request Aug 3, 2023
rPraml added a commit to FOCONIS/ebean that referenced this pull request Aug 3, 2023
rPraml added a commit to FOCONIS/ebean that referenced this pull request Aug 3, 2023
rPraml added a commit to FOCONIS/ebean that referenced this pull request Aug 8, 2023
rPraml added a commit to FOCONIS/ebean that referenced this pull request Aug 8, 2023
rPraml added a commit to FOCONIS/ebean that referenced this pull request Aug 9, 2023
rPraml added a commit to FOCONIS/ebean that referenced this pull request Aug 9, 2023
rPraml added a commit to FOCONIS/ebean that referenced this pull request Aug 9, 2023
rPraml added a commit to FOCONIS/ebean that referenced this pull request Aug 9, 2023
rPraml added a commit to FOCONIS/ebean that referenced this pull request Aug 9, 2023
rPraml added a commit to FOCONIS/ebean that referenced this pull request Aug 9, 2023
rPraml added a commit to FOCONIS/ebean that referenced this pull request Aug 9, 2023
rPraml added a commit to FOCONIS/ebean that referenced this pull request Aug 9, 2023
rPraml added a commit to FOCONIS/ebean that referenced this pull request Aug 9, 2023
rPraml added a commit to FOCONIS/ebean that referenced this pull request Aug 9, 2023
rPraml added a commit to FOCONIS/ebean that referenced this pull request Aug 10, 2023
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.

None yet

3 participants