Open
Description
When Teams configured to use a string as the primary key, the query appears to incorrectly map team_user.team_id to user_id instead of team_user.user_id. This results in a SQL error:
SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: character varying = bigint LINE 1: ...om "teams" inner join "team_user" on "teams"."id" = "team_us... ^ HINT: No operator matches the given name and argument types. You might need to add explicit type casts. (Connection: pgsql, SQL: select "teams".*, "team_user"."team_id" as "pivot_team_id", "team_user"."user_id" as "pivot_user_id", "team_user"."role_id" as "pivot_role_id", "team_user"."created_at" as "pivot_created_at", "team_user"."updated_at" as "pivot_updated_at" from "teams" inner join "team_user" on "teams"."id" = "team_user"."user_id" where "team_user"."team_id" = 1)
Steps to Reproduce
- Configure the teams table to use a string as the primary key.
- Attempt to query a relationship involving the team_user pivot table, for example:
$request->user()->allTeams();
- Observe that the query tries to map team_user.team_id to user_id instead of team_user.user_id, resulting in the SQL error.
Expected Behavior
The generated query should correctly map:
teams.id to team_user.team_id
users.id to team_user.user_id
Actual Behavior
The generated query incorrectly maps team_user. team_id to user_id, leading to a SQL error when executing the query.
Additional Context
This behavior appears to be incorrect, as it does not align with the expected relationships defined in the schema. Please advise if this is a bug or if additional configuration is needed to resolve this issue when using string primary keys.
Metadata
Metadata
Assignees
Labels
No labels