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'm comparing two schema, where the newer schema has new columns with data.
The data compare feature correctly creates the INSERT statement (populating the new columns with the values), but does not include the new columns in UPDATE statements.
Example :
-- SCHEMA ACREATETABLEpublic.test (
id serialNOT NULL,
"name"varcharNULL,
CONSTRAINT test_pk PRIMARY KEY (id)
);
INSERT INTO test VALUES (1, 'john');
-- SCHEMA BCREATETABLEpublic.test (
id serialNOT NULL,
"name"varcharNULL,
"surname"varcharNULL,
CONSTRAINT test_pk PRIMARY KEY (id)
);
INSERT INTO test VALUES (1, 'johnny', 'wayne');
INSERT INTO test VALUES (2, 'alfred', 'hitchcock');
-- ...ALTERTABLE IF EXISTS "public"."test" ADD COLUMN IF NOT EXISTS "surname"varcharNULL ;
-- ...INSERT INTO"public"."test" ("id", "name", "surname") VALUES (2, 'alfred', 'hitchcock');
UPDATE"public"."test"SET"name"='johnny'WHERE"id"=1;
-- ...
See that "john" is correctly updated to "johnny", but the "wayne" is not populated at all, while "hitchcock" is correctly populated for the newly inserted value.
The text was updated successfully, but these errors were encountered:
Hmm actually it doesn't seem linked to newly added columns, but just to NULL values as if I run my script in two steps (first update the schema, then create the diff) I run in the same issue...
Example :
-- SCHEMA ACREATETABLEpublic.test (
id serialNOT NULL,
"name"varcharNULL,
CONSTRAINT test_pk PRIMARY KEY (id)
);
INSERT INTO test VALUES (1, NULL);
-- SCHEMA BCREATETABLEpublic.test (
id serialNOT NULL,
"name"varcharNULL,
"surname"varcharNULL,
CONSTRAINT test_pk PRIMARY KEY (id)
);
INSERT INTO test VALUES (1, 'johnny');
INSERT INTO test VALUES (2, 'alfred');
I guess there must be a comparison issue in the code, something like WHERE olddata <> newdata, which will not correctly handle null values (to be replaced with WHERE olddata is distinct from newdata
olivierdalang
changed the title
Data compare doesn't insert values for new columns in update statement
Data compare doesn't detect updates of NULL values
Nov 8, 2021
olivierdalang
added a commit
to olivierdalang/pg-diff-api
that referenced
this issue
Nov 8, 2021
Hi !
I'm comparing two schema, where the newer schema has new columns with data.
The data compare feature correctly creates the INSERT statement (populating the new columns with the values), but does not include the new columns in UPDATE statements.
Example :
Using config
I get the script
See that "john" is correctly updated to "johnny", but the "wayne" is not populated at all, while "hitchcock" is correctly populated for the newly inserted value.
The text was updated successfully, but these errors were encountered: