Skip to content

[mongodb] Document duplicate keys behavior in BSON documents - #50

Merged
GromNaN merged 1 commit into
php:mainfrom
GromNaN:docs/mongodb-bson-duplicate-keys
Oct 23, 2026
Merged

GromNaN merged 1 commit into
php:mainfrom
GromNaN:docs/mongodb-bson-duplicate-keys

Conversation

@GromNaN

@GromNaN GromNaN commented Oct 23, 2026

Copy link
Copy Markdown
Member

The driver does not validate duplicate keys in BSON documents. This documents how Document handles them: iteration and the JSON conversions keep every element, get() and offsetGet() return the first value, and toPHP() keeps the last value.

The existing duplicate keys warning is updated to say that this behavior is covered by tests, but applications should still avoid duplicate keys.

@GromNaN GromNaN changed the title Document duplicate keys behavior in BSON documents [mongodb] Document duplicate keys behavior in BSON documents Oct 23, 2026

@jordikroon jordikroon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Feel free to merge.

@GromNaN
GromNaN force-pushed the docs/mongodb-bson-duplicate-keys branch from 8faef9a to 203f694 Compare October 23, 2026 17:52
@GromNaN
GromNaN merged commit 54d68a7 into php:main Oct 23, 2026
2 checks passed
@GromNaN
GromNaN deleted the docs/mongodb-bson-duplicate-keys branch October 23, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants