-
Notifications
You must be signed in to change notification settings - Fork 1
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
IBX-6634: Fixed relationship comparison #11
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,16 +48,38 @@ public function testInvalidField(): void | |
$this->expressionVisitor->dispatch(new Comparison('non_existent_field', '=', 'bar')); | ||
} | ||
|
||
public function testTraversingRelationships(): void | ||
/** | ||
* @dataProvider provideForTraversingRelationships | ||
*/ | ||
public function testTraversingRelationships(Comparison $expr, string $expectedResult): void | ||
{ | ||
// Note: This assumes relationship tables are joined before being used. | ||
$expr = new Comparison( | ||
'relationship_1.relationship_2.relationship_2_foo', | ||
'IN', | ||
'bar', | ||
); | ||
$result = $this->expressionVisitor->dispatch($expr); | ||
self::assertSame('relationship_2_table_name.relationship_2_foo = :relationship_2_foo_0', $result); | ||
self::assertSame($expectedResult, $result); | ||
} | ||
|
||
/** | ||
* @return iterable<array{\Doctrine\Common\Collections\Expr\Comparison, non-empty-string}> | ||
*/ | ||
public static function provideForTraversingRelationships(): iterable | ||
{ | ||
yield [ | ||
new Comparison( | ||
'relationship_1.relationship_2.relationship_2_foo', | ||
'IN', | ||
'bar', | ||
), | ||
'relationship_2_table_name.relationship_2_foo IN :relationship_2_foo_0', | ||
Comment on lines
+67
to
+72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TBH I don't follow there relationship between what you declare this relationship and what you get from it (pun intended), but I think we've already discussed this ages ago, so I'll just continue scrolling :D There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @alongosz could you rephrase? I don't quite understand what part of the above is the issue? Is it that we are declaring relationships between tables? |
||
]; | ||
|
||
yield [ | ||
new Comparison( | ||
'relationship_1.relationship_2.relationship_2_foo', | ||
'<', | ||
'2023-11-22 10:00:00', | ||
), | ||
'relationship_2_table_name.relationship_2_foo < :relationship_2_foo_0', | ||
]; | ||
} | ||
|
||
public function testInvalidRelationshipTraversal(): void | ||
|
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.
There's
\Doctrine\DBAL\Query\QueryBuilder::distinct
but maybe not usable here given it'sCOUNT(DISTINCT )
notDISTINCT COUNT()
?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.
Yes, due to the above it is not usable. I have actually checked and we have a similar code in our
ibexa/core
, and this syntax works for our supported databases.