Commit 5ab355a
authored
Permit outer joins when using update_all with PostreSQL (#457)
The PostgreSQL UPDATE command permits specifying multiple 'from_item'
expressions to allow columns from other tables to appear in the update
expression. In particular, the documentation explains (cf.
https://www.postgresql.org/docs/current/sql-update.html):
> This uses the same syntax as the FROM clause of a SELECT statement
Thus, a statement such as
UPDATE x
SET a = z.a
FROM y
LEFT_JOIN z ON z.i = y.i
is legal.
However, executing query like this this via Ecto would fail, raising an
error:
** (Ecto.QueryError) PostgreSQL supports only inner joins on update_all, got: `left` in query:
from x0 in "x",
join: y1 in "y",
on: true,
left_join: z2 in "z",
on: true,
update: [set: [a: 1]]
This PR fixes the issue by adding a `Postgres.Connection.using_join/4`
clause for the :update_all case: in this scenario, at least one inner
join has to be specified, but additional other joins are permissible.1 parent ddf4fb5 commit 5ab355a
2 files changed
Lines changed: 38 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
453 | 453 | | |
454 | 454 | | |
455 | 455 | | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
456 | 481 | | |
457 | 482 | | |
458 | 483 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
920 | 920 | | |
921 | 921 | | |
922 | 922 | | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
923 | 936 | | |
924 | 937 | | |
925 | 938 | | |
| |||
0 commit comments