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
Implemented EZP-21640: Implement RelationList search criterion #547
Conversation
This Pull Request does not respect our Coding Standards, please, see the report below:
|
This is awesome! :) |
{ | ||
return array( | ||
new Specifications( Operator::EQ, Specifications::FORMAT_SINGLE | Specifications::FORMAT_ARRAY, Specifications::TYPE_INTEGER ), | ||
new Specifications( Operator::IN, Specifications::FORMAT_ARRAY, Specifications::TYPE_INTEGER ), |
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.
Specification type should actually be Specifications::TYPE_INTEGER | Specifications::TYPE_STRING
, as in future NoSQL storage id
will be a hash (for this reason we always hint ids as mixed
and not int
).
Side note: @pspanja / @patrickallaert is the failure in commit above caused by postgres lack of ordering? https://travis-ci.org/ezsystems/ezpublish-kernel/jobs/12238878 |
Yes, well, in fact it is MySQL that returns values too frequently ordered by primary key even if no sorting asked ;-) But I saw some changes in this regard with MariaDB 5.5 (MySQL 5.5 as well?) where returned values were more randomly ordered. All tests needs indeed to be tested without any fixed ordering. |
Something @taenadil didn't mention is that... $query->criterion = new Criterion\RelationList(
"relation_field",
Operator::EQ,
42
); looks for content where the Content ID 42 resides in the $query->criterion = new Criterion\RelationList(
"relation_field",
Operator::EQ,
array( 42, 43 )
); looks for content where both the Content ID 42 AND 43 resides in the $query->criterion = new Criterion\RelationList(
"relation_field",
Operator::IN,
array( 42, 43 )
); looks for content where one of Content ID 42 OR 43 resides in the The following is not supported, and I am wondering if it should: $query->criterion = new Criterion\RelationList(
"relation_field",
Operator::IN,
array( array( 42, 43 ), array( 2, 3 ) )
); This would theoretically search for content where in the Other than that, huge +1 from me :-) Congrats @taenadil ! (#kernel-contribution-of-the-year ?) |
@patrickallaert Nice, but one possible thing: @pspanja introduced a ::CONTAINS word recently, so maybe that one is more suited to deal with the OR condition? |
Might be, but we miss a clear example about how to use |
@patrickallaert, @andrerom, @taenadil I'm ok how
I would rather not go for this, as it is already possible to achieve the same by using For On the other hand, I think this is intuitive and would cover all bases, but would probably be a pain to implement, or even not possible to do in a sane way. So this might be the best we can get, but I would suggest renaming What do you think? |
Perfectly agreed with all of your remarks. @taenadil +1 given you rename |
+1 as soon as Travis agrees :) Great work @taenadil! |
Travis seems to agree. Can we merge it now @pspanja @patrickallaert @andrerom ? |
Seems so, yes 👍 |
Merging... @andrerom 5.2 right? :) |
Implemented EZP-21640: Implement RelationList search criterion
@pspanja I guess so |
I'm all +1 but I was about to ask if it should be renamed to just "Relation", cause it works across all relation types right? There is nothing in here specific to RelationList FieldType? Or is there other reasons to call it "List" maybe ? |
@andrerom True, but we still might want to implement criterion for Content-level relations. So maybe "FieldRelation"? Edit: Actually, it might make sense to adapt this for all Relation types. |
Well, one FieldRelation and one ContentRelation with code reuse between each other can be good approach, otherwise field identifier needs to be made optional and we need to add relation type as param as well. |
@andrerom agreed, I'll open a PR. |
https://jira.ez.no/browse/EZP-21640
Currently, it is not possible to search for Content related (through RelationList) to a specific Content.
In Legacy, this criterion would basically add an additional join to table ezcontentobject_link.
Or: