Skip to content

Conversation

@ADmad
Copy link
Member

@ADmad ADmad commented Sep 26, 2025

Resolves #18929

dereuromark and others added 3 commits November 2, 2025 15:30
- 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
@dereuromark
Copy link
Member

dereuromark commented Nov 2, 2025

Is this PR already a improvement to before and mergable?
It seems to fix the main concern of the issue.

@dereuromark dereuromark marked this pull request as ready for review November 2, 2025 14:51
$options['includeFields'] = false;
}

$alias = $options['alias'] ?? $this->_name;
Copy link
Member

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;
Copy link
Member

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]);
Copy link
Member

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');
Copy link
Member

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?

@othercorey othercorey requested a review from Copilot November 8, 2025 02:17

This comment was marked as outdated.

@ADmad
Copy link
Member Author

ADmad commented Nov 8, 2025

Copying here the comment I had made on the initial PR made by dereuromark, after making this PR.

But it would still need more work. The test case you added only creates joins for the nested associations, doesn't actually select its fields. Changing the alias means most likely the nested entities won't be properly populated in the resultset.

So we need more tests ensuring the entities are populated correctly.

@cakephp cakephp deleted a comment from Copilot AI Nov 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants