You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently ODM does not support querying by any PHP object values, except DateTimeInterface and ObjectId, even if there are custom mapping types to convert this values to their DB representation.
This makes using of ODM pretty weird, when you can use your value objects in your documents (entities), but you must query this documents by database values.
After a little research I found that problem is in the Type::getTypeFromPHPVariable() method, which looks unfinished:
if (is_object($variable)) {
if ($variable instanceof DateTimeInterface) {
return self::getType('date');
}
if ($variable instanceof ObjectId) {
return self::getType('id');
}
} else {
//...
}
Here ODM explicitly ignores any objects except DateTimeInterface and ObjectId.
I believe that maybe this behavior is a result of ODM not having an explicit way to map PHP value to custom mapping type. However, there is a mapping from field name to field type, and this info may be used to properly convert value.
Current behavior
No ability to search by PHP object values, used in custom mapping types.
How to reproduce
Create custom mapping types, which converts php object to some scalar value for storing in DB.
Create document, which uses this custom mapping type.
Try to query by a "php value" used in custom type.
Query will not find anything ever,
Expected behavior
I expect to be able to query by PHP objects, used as a type of a field in my document.
The text was updated successfully, but these errors were encountered:
@alcaeus from what I see, this is pretty straightforward to add this feature. Actually, you can see my PR, which adds this feature at least for non-array values.
For now all tests pass, except one error in the last job (with DEPLOYMENT=REPLICASET), but I believe that maybe it is not related to changes I made in this PR.
If you have any comments on that PR, I would be happy to fix it.
Bug Report
Summary
Currently ODM does not support querying by any PHP object values, except
DateTimeInterface
andObjectId
, even if there are custom mapping types to convert this values to their DB representation.This makes using of ODM pretty weird, when you can use your value objects in your documents (entities), but you must query this documents by database values.
After a little research I found that problem is in the
Type::getTypeFromPHPVariable()
method, which looks unfinished:Here ODM explicitly ignores any objects except
DateTimeInterface
andObjectId
.I believe that maybe this behavior is a result of ODM not having an explicit way to map PHP value to custom mapping type. However, there is a mapping from field name to field type, and this info may be used to properly convert value.
Current behavior
No ability to search by PHP object values, used in custom mapping types.
How to reproduce
Expected behavior
I expect to be able to query by PHP objects, used as a type of a field in my document.
The text was updated successfully, but these errors were encountered: