You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have two tables for which I added a join and used the upsert option.
One table zones and one table status. For each zone, there must be a status defined. Usually, features will be added on zones and corresponding statuses need to be created.
When I add a new zone, it tries to insert a new status indeed, but fails because the id of it is NULL. It seems not to be taking the primary key for the new status from the database serial.
Looking at #33148 which looks very, very similar but it's actually inverted. There, the user starts with the "parent" table and joins a "child" (analogue here: add a status and upsert a zone).
From what I understand, currently the default value needs to be defined on the "main" table field (zones.status_id) while in most of the scenarios I can come up with, the opposite would be the case.
The documentation is silent on default value handling for upsert joins, so I wonder if this requirement here would rather be a new feature than a bug.
CREATESEQUENCEpublic.zone_id_seq;
CREATETABLEpublic.zones
(
id integerNOT NULL DEFAULT nextval('public.zone_id_seq'::regclass),
type character varying,
status_id integer,
CONSTRAINT zone_pkey PRIMARY KEY (id)
CONSTRAINT zone_status_id_fkey FOREIGN KEY (status_id)
REFERENCESpublic.status (id) MATCH SIMPLE
);
CREATESEQUENCEpublic.status_id_seq;
CREATETABLEpublic.status
(
id integerNOT NULL DEFAULT nextval('public.status_id_seq'::regclass),
name character varying,
CONSTRAINT status_pkey PRIMARY KEY (id),
);
The text was updated successfully, but these errors were encountered:
m-kuhn
added
the
Bug
Either a bug report, or a bug fix. Let's hope for the latter!
label
Aug 15, 2020
I have two tables for which I added a join and used the upsert option.
One table
zones
and one tablestatus
. For each zone, there must be a status defined. Usually, features will be added on zones and corresponding statuses need to be created.When I add a new zone, it tries to insert a new status indeed, but fails because the id of it is NULL. It seems not to be taking the primary key for the new status from the database serial.
Looking at #33148 which looks very, very similar but it's actually inverted. There, the user starts with the "parent" table and joins a "child" (analogue here: add a status and upsert a zone).
From what I understand, currently the default value needs to be defined on the "main" table field (zones.status_id) while in most of the scenarios I can come up with, the opposite would be the case.
The documentation is silent on default value handling for upsert joins, so I wonder if this requirement here would rather be a new feature than a bug.
The text was updated successfully, but these errors were encountered: