We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
@Entity() export class Message extends BaseIdEntity { @ManyToMany({pivotTable: 'message_to_deletion'}) deletions: Collection<User> = new Collection<User>(this);
This is a query which matches a non-null value on the M:N deletions field:
deletions
em.find(Message, { group: groupId, deletions: 1, });
This is the sql that gets generated:
select "e0".*, "e1"."message_id", "e1"."user_id" from "message" as "e0" left join "message_to_deletion" as "e1" on "e0"."id" = "e1"."message_id" where "e0"."group_id" = 1 and "e1"."user_id" = 1
So far so good.
Now let's try to match a null value instead:
em.find(Message, { group: groupId, deletions: null, });
This is what gets generated:
select "e0".*, "e1"."message_id", "e1"."user_id" from "message" as "e0" left join "message_to_deletion" as "e1" on "e0"."id" = "e1"."message_id" where "e0"."group_id" = 25 and "e0"."deletions" is null
This obviously won't work, because deletions is not a column.
Expected behavior
select "e0".*, "e1"."message_id", "e1"."user_id" from "message" as "e0" left join "message_to_deletion" as "e1" on "e0"."id" = "e1"."message_id" where "e0"."group_id" = 1 and "e1"."user_id" is null
Additional context
em.find(Message, { group: groupId, deletions: {id: null}, });
The previous workaround works, but with some caveats: in fact having to explicitly specify the PK column will trigger an unnecessary join, see #549
Versions
The text was updated successfully, but these errors were encountered:
fix(sql): pivot joining of m:n when target entity is null
fdc9e06
Closes #548
Closing as fixed in dev via fdc9e06
Sorry, something went wrong.
0a55a99
2da29ee
3b05a59
B4nan
No branches or pull requests
This is a query which matches a non-null value on the M:N
deletions
field:This is the sql that gets generated:
So far so good.
Now let's try to match a null value instead:
This is what gets generated:
This obviously won't work, because
deletions
is not a column.Expected behavior
Additional context
The previous workaround works, but with some caveats: in fact having to explicitly specify the PK column will trigger an unnecessary join, see #549
Versions
The text was updated successfully, but these errors were encountered: