-
-
Notifications
You must be signed in to change notification settings - Fork 190
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
Reference ids in subdocuments saved as string #256
Comments
I think you need read MongoId specifics |
You didn't get it. It is not string 'abcabcabcabcabcabcabc' which can be cast to ObjectId but string: 'MongoDB\BSON\ObjectID(abcabcabcabcabcabcabc)' which cannot! If I leave 'abcabcabcabcabcabcabc' I will have string in DB not the proper ObjectId. There is now way to save ObjectId as a document property which is an array type. Why it is cast to a string with class name? |
You must cast it before set to entity when it is ObjectID: $model = $this->findModel($intent);
$entity = $this->findOtherModel($id);
$model->parameters = [
[
'entity' => (string) $entity->_id,
'value' => '1'
],
[
'entity' => (string) $entity->_id,
'value' => '2'
],
];
$model->save(); may work |
Nope, you get string, not the ObjectId. The question is why it is cast to weird string - 'MongoDB\BSON\ObjectID(abcabcabcabcabcabcabc)' rather than leave as ordinary ObjectId?
it works (leave ObjectId). |
What steps will reproduce the problem?
What's expected?
ObjectId
What do you get instead?
String
Additional info
it generates BulkWrite query to MongoDB. All of 'enitity' attributes in array of subdocuments are casted to String 'MongoDB\BSON\ObjectID(abcabcabcabcabcabcabc)'. Is anyone know why and how to fi this?
The text was updated successfully, but these errors were encountered: