-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Fix duplicate nested association aliases #18932
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
base: 5.next
Are you sure you want to change the base?
Conversation
- Add proper PHPDoc type annotations for method parameters and return value - Extract str_replace() results into named variables for better readability - Resolves PHPStan errors about possibly invalid array key types 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…d-assoc-alias # Conflicts: # tests/TestCase/ORM/Query/SelectQueryTest.php
|
Is this PR already a improvement to before and mergable? |
| $options['includeFields'] = false; | ||
| } | ||
|
|
||
| $alias = $options['alias'] ?? $this->_name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not add this to the $options merge above?
| { | ||
| $conditions = []; | ||
| $tAlias = $this->_name; | ||
| $tAlias = $options['alias'] ?? $this->_name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this already be defaulted above?
| $existingKey = str_replace('.', '_', $existingPath); | ||
| if (!isset($result[$existingKey])) { | ||
| $result[$existingKey] = $result[$nestedAlias]; | ||
| unset($result[$nestedAlias]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we conditionally unset this?
|
|
||
| // Check that we have unique aliases for the Comments table joins | ||
| // Creator.Comments should be aliased as Creator_Comments | ||
| $this->assertStringContainsString('Creator_Comments', $sql, 'Creator.Comments should use unique alias Creator_Comments'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't assertEqualsSql() do this?
|
Copying here the comment I had made on the initial PR made by dereuromark, after making this PR.
So we need more tests ensuring the entities are populated correctly. |
Resolves #18929