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
Proving bug with Deep nested many_many relations #3839
Proving bug with Deep nested many_many relations #3839
Conversation
Ok, So I've fixed an issue where the There remains a problem with the actual filter due to the collision of the table names and thus the |
36c1fb7
to
7a3cb15
Compare
@tractorcow I'd like you're thoughts on whether your ORM work will have fixed this problem? |
I doubt it, I don't think I've tested this specific use case. |
You need to ensure you add any class with TestOnly interface to extraDataObjects variable. |
340c1d4
to
5f58c8a
Compare
thanks @tractorcow added that and now looks like the real reason for failing is happening |
Did you want to fix these tests? :D I think this should be merged soon. |
5f58c8a
to
8e669f7
Compare
8e669f7
to
e26a323
Compare
Ok, the tests aren't broken, it's the core itself. For some reason the query builder is joining on the wrong column for the link table. |
@dhensby any enthusiasm for remedying whatever is broken in these? |
Yep, is a pretty serious bug, it's all about time for free at the moment... :( |
This API has changed a lot in later branches... you probably don't want to leave this too long before the branches diverge. :P I would close and re-open on 3.3 if I were you. |
Just ran into this one, nasty 😢 . Don’t suppose you’ve had a chance to look at this yet @dhensby? |
if (!$this->query->isJoinedTo($componentBaseClass)) { | ||
$this->query->addLeftJoin($componentBaseClass, | ||
"\"$relationTable\".\"$componentField\" = \"$componentBaseClass\".\"ID\""); | ||
} | ||
if(ClassInfo::hasTable($componentClass)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My example also needed !$this->query->isJoinedTo($componentClass)
added to this condition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm.. maybe you'd need to do that if the field that needed to be filtered on was not on the componentBaseClass
?
83e15c8
to
82ba66f
Compare
I've gone and refreshed my memory with this issue. There are two problems here which I've now resolved, though perhaps not completely and in a very hacky and non-semver way.
I think this has been resolved, though @kinglozzer doesn't seem to agree. Because
If you have a relationship between the same ancestor classes (eg: The generated SQL for SELECT "SiteTree".*
FROM "SiteTree"
INNER JOIN "SomePage_RelatedPages" ON "SomePage_RelatedPages"."SomePageID" = "SiteTree"."ID"
WHERE "SiteTree"."ID" IN (1,2,3) AND "SiteTree"."ClassName" = 'SomePage'; This fails to return results as the join is not done properly and should be something closer to: SELECT "SomePage".*
FROM "SiteTree" AS "SomePage"
INNER JOIN "SomePage_RelatedPages" ON "SomePage_RelatedPages"."SomePageID" = "SomePage"."ID"
INNER JOIN "SiteTree" AS "RelatedPage" ON "SomePage_RelatedPages"."RelatedPageID" = "RelatedPage"."ID"
WHERE "RelatedPage"."ID" IN (1,2,3) AND "SomePage"."ClassName" = 'SomePage' This is a difficult problem to solve as the |
a2dcfe5
to
2fd5cad
Compare
When adding a filter to a many_many with a shared inheritance, the FROM table is removed and added as a LEFT JOIN which causes a syntax error. This means `$dataList->filter('ManyManyRel.ID', array(1,2))` doesn't work.
99f550f
to
2b15eb6
Compare
When adding a filter to a many_many with a shared inheritance, the FROM table is removed and added as a LEFT JOIN which causes a syntax error.
This means
$dataList->filter('ManyManyRel.ID', array(1,2))
doesn't work.