Postgres editor empty string bug

madmoizoHOBBY

9 months ago

There is a bug when updating a row in postgres service data tab.

Considering the simplified database schema:

CREATE TABLE "User" (

"id" TEXT NOT NULL,

"firstname" TEXT NOT NULL DEFAULT '',

"lastname" TEXT NOT NULL DEFAULT ''

);

Step to reproduce:

  • Go to the data tab of your postgresql service

  • Select the "User" table

  • Add a new row -> it works

  • Edit the new row by clicking on it

  • Change the "firstname", leave the "lastname" empty

  • Click on save -> the UI shows a "check" icon but nothing happens

Going to the Deploy logs will show the following error:

ERROR: null value in column "lastname" of relation "User" violates not-null constraint

DETAIL: Failing row contains ('abcd', 'John', null).

STATEMENT: update "public"."User" set "id" = 'abcd', "firstname" = 'John', "lastname" = NULL

Issues:

1 - The edit processing seems to convert empty string to NULL which is incorrect.

The correct statement should be:

update "public"."User" set "id" = 'abcd', "firstname" = 'John', "lastname" = ''

2 - The edit UI show a (success) check icon after clicking on save instead of displaying the error

0 Replies