-
Notifications
You must be signed in to change notification settings - Fork 6
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
Clarify how associative arrays as document values should be updated. #17
Comments
@sandrokeil @martin-schilling @heiglandreas @jsor @sblum I consider this a bugfix and would release a |
Thank you for investigation and the PRs @internalsystemerror 👏 |
Just for completeness sake, I think I still remember the reason Just out of curiosity though, how do other DBs behave? It might be worth checking how this works in other popular DBs like MongoDB to make sure that the most suitable procedure can be chosen. Afterwards this behavior should probably be defined and documented so that we don't have this problem in the future anymore. Thanks for the PR! |
Good points @martin-schilling . I ask @sandrokeil tomorrow regarding MongoDB. |
MongoDB has a $set operator and it behaves similar to Postgres. I'm going to merge the PRs now. |
Fixed with #18 |
Assuming the following:
The
InMemoryDocumentStore
would merge thePayload::USER_VALIDATIONS
arrays recursively, adding additional values. This provides no way of removing a nested key. There is even a test to enforce this behaviour: https://github.com/event-engine/php-document-store/blob/1e980c8e8e3f7b48428740e109692440dffa3a2b/tests/InMemoryDocumentStoreTest.php#L88-112Further, the
event-engine/php-postgres-document-store
handles this differently, where merges are NOT recursive: https://github.com/event-engine/php-postgres-document-store/blob/e9721e21f42a648a79eb9865b5656c6949bf1c42/src/PostgresDocumentStore.php#L366For more on how the
||
operator is used: https://www.postgresql.org/docs/13/functions-json.htmlI have submitted the following PRs for changes:
event-engine/php-postgres-document-store
to confirm that associative arrays are not merged recursively (tests: confirm that (and how) associative array values are handled in updates php-postgres-document-store#15).InMemoryDocumentStore
to conform to the behaviour ofevent-engine/php-postgres-document-store
(fix: Mimic how postgres-document-store works, where documents are not merged recursively. #18).The text was updated successfully, but these errors were encountered: