|
66 | 66 | use function property_exists;
|
67 | 67 | use function serialize;
|
68 | 68 | use function sprintf;
|
| 69 | +use function str_contains; |
69 | 70 | use function str_ends_with;
|
70 | 71 | use function str_replace;
|
71 | 72 | use function str_starts_with;
|
@@ -1616,7 +1617,24 @@ private function aliasIdForQuery(array $values): array
|
1616 | 1617 | }
|
1617 | 1618 |
|
1618 | 1619 | foreach ($values as $key => $value) {
|
1619 |
| - if (is_string($key) && str_ends_with($key, '.id')) { |
| 1620 | + if (! is_string($key)) { |
| 1621 | + continue; |
| 1622 | + } |
| 1623 | + |
| 1624 | + // "->" arrow notation for subfields is an alias for "." dot notation |
| 1625 | + if (str_contains($key, '->')) { |
| 1626 | + $newkey = str_replace('->', '.', $key); |
| 1627 | + if (array_key_exists($newkey, $values) && $value !== $values[$newkey]) { |
| 1628 | + throw new InvalidArgumentException(sprintf('Cannot have both "%s" and "%s" fields.', $key, $newkey)); |
| 1629 | + } |
| 1630 | + |
| 1631 | + $values[$newkey] = $value; |
| 1632 | + unset($values[$key]); |
| 1633 | + $key = $newkey; |
| 1634 | + } |
| 1635 | + |
| 1636 | + // ".id" subfield are alias for "._id" |
| 1637 | + if (str_ends_with($key, '.id')) { |
1620 | 1638 | $newkey = substr($key, 0, -3) . '._id';
|
1621 | 1639 | if (array_key_exists($newkey, $values) && $value !== $values[$newkey]) {
|
1622 | 1640 | throw new InvalidArgumentException(sprintf('Cannot have both "%s" and "%s" fields.', $key, $newkey));
|
|
0 commit comments