Need help in solving an issue when one of the values' columns contains only Null
values. Example:
create table foo (
id serial constraint foo_pk primary key,
a int,
b int
);
insert into foo (a,b) values (1, 1), (2, 2);
update foo t
set a = v.a, b = v.b
from (values (1, NULL, 1),(2, NULL, 2)) as v(id, a, b)
where v.id = t.id;
This gives me:
[42804] ERROR: column "a" is of type integer but expression is of type text
Hint: You will need to rewrite or cast the expression. Position: 22
I'm using psycopg2.extras.execute_values
in order to update multiple Django ORM objects. Looking for a solution that doesn't need to cast nulls to field types explicitly.