Skip to content

fix(database): relations joins overshadowing if property name conflict in chain#2064

Open
laylatichy wants to merge 9 commits intotempestphp:3.xfrom
laylatichy:fix-belongs-to-many-relation-joins
Open

fix(database): relations joins overshadowing if property name conflict in chain#2064
laylatichy wants to merge 9 commits intotempestphp:3.xfrom
laylatichy:fix-belongs-to-many-relation-joins

Conversation

@laylatichy
Copy link
Contributor

@laylatichy laylatichy commented Mar 21, 2026

in a case the parent model has the same property name as child model one is overshadowed leading to invalid query

Given models like this:

final class User
{
    public Role $role;

    #[BelongsToMany]
    public array $permissions;
}

final class Role
{
    #[BelongsToMany]
    public array $permissions;
}

final class Permission
{
    public string $label;
}

User::select()->with('role', 'role.permissions', 'permissions')->all();

would lead to user.role.permissions being overshadowed by user.permissions and dropped

@laylatichy laylatichy force-pushed the fix-belongs-to-many-relation-joins branch from f882200 to b62b6fc Compare March 21, 2026 21:46
@github-actions
Copy link

github-actions bot commented Mar 21, 2026

Benchmark Results

Comparison of fix-belongs-to-many-relation-joins against 3.x (3d5833ee0dc13c60845bb421f5cb72e3ac9b1452).

Open to see the benchmark results

No benchmark changes above ±5%.

Generated by phpbench against commit 46de25e

@laylatichy laylatichy force-pushed the fix-belongs-to-many-relation-joins branch from b62b6fc to b883d97 Compare March 21, 2026 21:47
@laylatichy laylatichy force-pushed the fix-belongs-to-many-relation-joins branch from b883d97 to 2ea0c63 Compare March 21, 2026 21:48
@laylatichy laylatichy changed the title fix(database): belongs to many relation joins fix(database): belongs to many relation joins overshadowing Mar 21, 2026
@laylatichy laylatichy changed the title fix(database): belongs to many relation joins overshadowing fix(database): relations joins overshadowing if property name conflict in chain Mar 21, 2026
@laylatichy laylatichy force-pushed the fix-belongs-to-many-relation-joins branch from 99b2b17 to 69f4473 Compare March 21, 2026 22:23
@laylatichy laylatichy force-pushed the fix-belongs-to-many-relation-joins branch from 69f4473 to 46de25e Compare March 21, 2026 22:24
@laylatichy laylatichy marked this pull request as ready for review March 21, 2026 22:44
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.

1 participant