Suppose I have three tables, a
, b
and c
:
create table c ( id serial primary key, can_edit_b boolean not null);create table b ( id serial primary key, value text not null);create table a ( id serial primary key, c_id integer not null references c(id), b_id integer not null references b(id));
I want to update b
(given an id for an instance of c
) so long as that instance of c
is referenced by an instance of a
which also references b
and c.can_edit_b
is true. The SQL for what I want to do:
update bset value = "some value"from c, awhere a.b_id == b.idwhere a.c_id == <user id (inserted as a Rust i32)>where c.can_edit_b == true
I can't find the relevant method/function in Diesel's API which corresponds to an SQL from
. If I try and use inner_join
then the compiler tells me that inner_join
is not defined for UpdateStatement
.