Closed svsool closed 7 years ago
looks like I need fix some tests
Tests are not the main problem. There are few other: 1) Back compatibility, when code starts to save {} but on modify expects [] 2) Hydrating new document object with {} in field. With your code, if you save document first time, you'v got {} in db, then you read document and this field became [], because driver do not distinguish [] and {} on read from db.
So this must be done by specifying type of field, or something like that. Then hydrated and repeatedly saved document also will have {}.
By the way, why do you need {} in db, you may omit saving this field, and modilying empty field must be correctly handled.
Some legacy code may require this, but I agree with you anyway
I.l add field type functionality snd inform you here https://github.com/sokil/php-mongo/issues/144
more information you can find here https://jira.mongodb.org/browse/PHP-172
sometimes you need save empty plain object {} as value
result:
but now it always saved as ↓, because value casts to array