Skip to content

fix for root id being overwritten #3401

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1774,7 +1774,7 @@ public function orWhereIntegerNotInRaw($column, $values, $boolean = 'and')

private function aliasIdForQuery(array $values, bool $root = true): array
{
if (array_key_exists('id', $values) && ($root || $this->connection->getRenameEmbeddedIdField())) {
if (array_key_exists('id', $values) && ($this->connection->getRenameEmbeddedIdField())) {
if (array_key_exists('_id', $values) && $values['id'] !== $values['_id']) {
throw new InvalidArgumentException('Cannot have both "id" and "_id" fields.');
}
Expand Down Expand Up @@ -1837,7 +1837,7 @@ public function aliasIdForResult(array|object $values, bool $root = true): array
if (is_array($values)) {
if (
array_key_exists('_id', $values) && ! array_key_exists('id', $values)
&& ($root || $this->connection->getRenameEmbeddedIdField())
&& ($this->connection->getRenameEmbeddedIdField())
) {
$values['id'] = $values['_id'];
unset($values['_id']);
Expand All @@ -1856,7 +1856,7 @@ public function aliasIdForResult(array|object $values, bool $root = true): array
if ($values instanceof stdClass) {
if (
property_exists($values, '_id') && ! property_exists($values, 'id')
&& ($root || $this->connection->getRenameEmbeddedIdField())
&& ($this->connection->getRenameEmbeddedIdField())
) {
$values->id = $values->_id;
unset($values->_id);
Expand Down