Join() being ignored when using Delete()
Hello. I am wanting to create a SQL statement that involves a DELETE and JOIN keyword. Here is a small example:
```sql
DELETE
FROM role_refs
JOIN roles as role ON role.id = id
WHERE role.name = 'Admin'
# role_ref and role is a many-to-one relationship; a role_ref can be matched with a single role at most.
```
Using go-pg, I'm using this code to mirror the above statement:
```go
Model((*RoleRef)(nil)).
Join(`JOIN roles as role ON role.id = id`).
Where(`role.name = ?`, "Admin").
Delete()
```
The table and column names don't really matter, but rather it's using both Join() and Delete(). However, when I execute the go-pg code, the assembled SQL statement is missing the JOIN statement completely:
```sql
DELETE
FROM role_refs
WHERE role.name = 'Admin'
```
I also tried replacing `Join()` with `Relation()` but there is no JOIN keyword in the resulting SQL either.
Is this a bug?
关闭于 2023-03-11 3 条评论