-
-
Notifications
You must be signed in to change notification settings - Fork 224
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
FEATURE: Add PropertyValueCriteriaMatcher
#4701
FEATURE: Add PropertyValueCriteriaMatcher
#4701
Conversation
d0e65c5
to
a8b2eec
Compare
I really like the idea but im not sure how we could check if its working as intended ... wait yes i do!!! We could adjust the subgraph implementation of a few methods to not the db filtering but filter the nodes via php and see if the e2e test like it ^^ |
Maybe the proposed inMemoryGraph has a use for this aswell :-) |
So i did it exactly as described above in #4710 and i noticed two kind of failing tests: Not using strict
|
When I execute the findDescendantNodes query for entry node aggregate id "home" and filter '{"propertyValue": "stringProperty = true"}' I expect no nodes to be returned |
descendantNodes.feature
When I execute the findDescendantNodes query for entry node aggregate id "home" and filter '{"propertyValue": "stringProperty = true"}' I expect no nodes to be returned # Features/NodeTraversal/DescendantNodes.feature:112
findDescendantNodes returned an unexpected result
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
-Array &0 ()
+Array &0 (
+ 0 => 'b'
+ 1 => 'b1'
+)
String comparison is lowercase in mariadb in PropertyValueContains
001 Scenario: # Features/NodeTraversal/DescendantNodes.feature:100
When I execute the findDescendantNodes query for entry node aggregate id "home" and filter '{"propertyValue": "stringProperty *= \"späci\" OR text $= \"a1\""}' I expect the nodes "b,a1,a2a1" to be returned # Features/NodeTraversal/DescendantNodes.feature:126
findDescendantNodes returned an unexpected result
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
Array &0 (
- 0 => 'b'
- 1 => 'a1'
- 2 => 'a2a1'
+ 0 => 'a1'
+ 1 => 'a2a1'
)
you can find my adjustments here
63a1e0a - if the tests also pass in ci, ill add them to your pr
I am not sure we would consider the MariaDB behavior correct by default. Imho we should discuss what we consider correct here. |
Additionally i like to discuss the location of this matcher. With But now it seems like we want to use it at other places as well - similar to PropertyValueCriteriaMatcher ^^ What do you say @bwaidelich? |
And Postgres was exactly the opposite where its always case sensitive? isnt it? |
@nezaniel can you help us to determine what the best default should be. Personally think the php implementation should be the best match and db-drivers should try to be as compatible as conveniently possible. Imho it is fine that using a specific database can have pros and cons. |
Converted to draft as the case-sensitivity of the property value operations still has to be defined. Until that is done this is on hold. |
See #4721 |
With the case insensitive matches merged: #4725 this is now unblocked. |
a8b2eec
to
5f2db40
Compare
cd355df
to
79ffd95
Compare
With #4721 solved this is updated and now handles case sensitivity. |
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.
Great one, thanks!
Just a comment re switch
vs match
...y.Core/Classes/Projection/ContentGraph/Filter/PropertyValue/PropertyValueCriteriaMatcher.php
Outdated
Show resolved
Hide resolved
Neos.ContentRepository.Core/Classes/Feature/NodeModification/Dto/SerializedPropertyValues.php
Outdated
Show resolved
Hide resolved
The property value criteria matcher accepts a ``PropertyValueCriteriaInterface`` and provides static methods to check wether a ``Node`` or a ``PropertyCollection`` matches those criteria.
79ffd95
to
b28aeb1
Compare
…lter/PropertyValue/PropertyValueCriteriaMatcher.php Co-authored-by: Bastian Waidelich <[email protected]>
… is hard to get at times
As last time i again run the The previous matter of case sensitivity was resolved, but the also mentioned issue
The inline doc also specifically denotes that strict comparison should be used
Testrunner: #4898 |
...y.Core/Classes/Projection/ContentGraph/Filter/PropertyValue/PropertyValueCriteriaMatcher.php
Outdated
Show resolved
Hide resolved
return static::matchesPropertyCollection($node->properties, $propertyValueCriteria); | ||
} | ||
|
||
public static function matchesPropertyCollection(PropertyCollection $propertyCollection, PropertyValueCriteriaInterface $propertyValueCriteria): bool |
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.
i like to propose to use here as first parameter the serialised node properties directly. Using the higher level object is not necessary and might even introduce bugs as the matching should only happen on the serialised properties. Also it will be easier to test.
A last testrun is now triggered at #4898 but i assume everything will be green and youll get my approval :D
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.
Not sure this is an actual benefit. In which usecase would one have serialized properties but not the propertyCollection.
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.
Introduded matchesSerializedPropertyValues
as separate method that is used by matchNode
and matchPropertyCollection
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.
Thänks. My reasoning here was just simply that when developing i came mostly across the SerializedPropertyValues
and not the abstraction of the PropertyCollection
which is not always available and harder to construct as it needs the serialiser. Also by passing in the serialised properties it becomes more obvious that the filtering happens on that level..
Tests at #4898 pass :D So its now basically a 1 to 1 implementation as far as the e2e testsuite says :) |
`matchesNode` and `matchesPropertyCollection` internally use this method
…pertyConverter` The `NodeSubjectProvider` will change in the future.
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.
Thank you for the adjustments and fixing everything.
The property value criteria matcher accepts a
PropertyValueCriteriaInterface
and provides static methods to check wether aNode
or aPropertyCollection
matches those criteria. This allows to use PHP for filtering nodes that were already fetched using the cr-property criteria.Notes:
PropertyValueCriteriaMatcher
operates on the serialized values to be as close to the database operations as possible.PropertyValueCriteriaMatcher
is merked @internal for now as is the theNodeType/ConstraintCheck
that does very similar things.Upgrade instructions
Review instructions
The review should check carefully that the implementation is in line with the checks in the db-drivers.
Also please note that i tried to write this as
match
statement but die not manage to get readable results for values that have to be read to a variable before checking.Checklist
FEATURE|TASK|BUGFIX
!!!
and have upgrade-instructions