[BUG] Postgres - Default Value for TEXT or VARCHAR (without length) shows up as issue, unable to specify empty string as default
Describe the bug Table field default values for TEXT or VARCHAR (without length) shows up as an issue but produces valid PostgreSQL schema. Wrapping the default value in quotes just adds those quotes to the default value.
Adding a length value back for VARCHAR makes the issue disappear.
Furthermore, I would expect entering two double or single quotes into the defaults field to produce DEFAULT '', but this is not the case. It shows up as DEFAULT '""' instead. This was apparently fixed with #10 but I don't understand how the code in the referenced commits actually would do that, and it apparently doesn't.
To Reproduce Steps to reproduce the behavior:
- Create new Diagram with Postgres, create a new Table
- Add a field with type TEXT or VARCHAR (remove length)
- Type in anything into the default value field
- See it show up in issues
Expected behavior Anything entered into the default value field for any text type should not produce an issue, since it clearly isn't one. There should be a way to specify an empty string as a default value.
Screenshots
This is the only way to specify a default value for a TEXT/VARCHAR field. Removing 255 or using TEXT as type results in the issue. Also entering "" into default results in unexprected SQL schema, see below.
Desktop (please complete the following information):
- OS: Linux
- Browser: Firefox
- DrawDB: Docker Image (ghcr.io/drawdb-io/drawdb:v1.8.1)
Additional context The exported SQL for the table:
CREATE TABLE IF NOT EXISTS "text_test" (
"id" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"text" TEXT NOT NULL DEFAULT 'test',
"varchar" VARCHAR NOT NULL DEFAULT 'test',
"varchar255" VARCHAR(255) NOT NULL DEFAULT 'test',
"empty_string" VARCHAR(255) NOT NULL DEFAULT '""',
PRIMARY KEY("id")
);Source: drawdb-io/drawdb