Support ENUM column types in table designer and data grid on PostgreSQL
Describe the bug Cannot edit nor select nor see ENUM types in postgres, instead heidi shows: UNKNOWN type (and thats all, not even name for that type from pg).
To Reproduce Steps to reproduce the behavior:
- Create any table with any enum type
Expected behavior
- Show the enum type and enum options
- Allow edit of enum options (x)
- Allow creation of enum options (x)
(x) => maybe as additional popup or something?
Environment:
- OS: [Windows 10]
- HeidiSQL version [11.0.0.5919]
- Database type and version [Postgress 11.6]
Please retry with the latest HeidiSQL build, and also provide a valid CREATE TABLE code with an ENUM column.
Create according to heidi
CREATE TABLE "files" (
"id" INTEGER NOT NULL DEFAULT 'nextval(''files_id_seq''::regclass)',
"isDeleted" BOOLEAN NULL DEFAULT 'false',
"createdAt" TIMESTAMPTZ NULL DEFAULT NULL,
"updatedAt" TIMESTAMPTZ NULL DEFAULT NULL,
"name" VARCHAR(250) NULL DEFAULT NULL,
"mimeType" VARCHAR(35) NULL DEFAULT NULL,
"objectId" INTEGER NOT NULL,
"uri" VARCHAR(512) NULL DEFAULT NULL,
"size" INTEGER NULL DEFAULT NULL,
"createdBy" INTEGER NULL DEFAULT NULL,
"updatedBy" INTEGER NULL DEFAULT NULL,
"objectMeta" VARCHAR(50) NULL DEFAULT NULL,
"objectType" UNKNOWN NULL DEFAULT NULL,
PRIMARY KEY ("id"),
INDEX "index__key__files__isDeleted" ("isDeleted"),
INDEX "index__key__files__objectType_objectId" ("objectType", "objectId"),
INDEX "index__key__files__objectType_objectMeta_objectId" ("objectType", "objectMeta", "objectId")
)
;
Real create
CREATE TABLE public.files
(
id integer NOT NULL DEFAULT nextval('files_id_seq'::regclass),
"isDeleted" boolean DEFAULT false,
"createdAt" timestamp with time zone,
"updatedAt" timestamp with time zone,
name character varying(250) COLLATE pg_catalog."default",
"mimeType" character varying(35) COLLATE pg_catalog."default",
"objectType" "enum_files_objectType" NOT NULL,
"objectId" integer NOT NULL,
uri character varying(512) COLLATE pg_catalog."default",
size integer,
"createdBy" integer,
"updatedBy" integer,
CONSTRAINT files_pkey PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
CREATE INDEX "index__key__files__isDeleted"
ON public.files USING btree
("isDeleted" ASC NULLS LAST)
TABLESPACE pg_default;
-- Index: index__key__files__objectType_objectId
-- DROP INDEX public."index__key__files__objectType_objectId";
CREATE INDEX "index__key__files__objectType_objectId"
ON public.files USING btree
("objectType" ASC NULLS LAST, "objectId" ASC NULLS LAST)
TABLESPACE pg_default;
Where "enum_files_objectType" is the enum type
CREATE TYPE public."enum_files_objectType" AS ENUM
('guideline', 'project', 'vendor', 'image', 'image-letterMark', 'item', 'item-letterMark');
Do you need any help with this issue? Anything i can help you with?
So PostgreSQL allows creating a custom enumeration which you can use as a data type?
Yes (for me its stupid thought) but there are some nice things about it too.
- Posgtres allows to create type with validation, enums etc
- It is named in one namespace
- several tables/fields in table can reuse the same enum
- adding values to enum is simple, removing - harder
- deleting table do not remove the custom type
- creating table can reuse not deleted custom type
There is more, but im not master in postgres, im just forced to use it lately on projects so i try to learn as much as i can and share if possible
Here is a link for documentation https://www.postgresql.org/docs/9.2/sql-createtype.html you can see that most common types created by users are - enum[s] and range[s].
Hello, here is the current version of the manual: https://www.postgresql.org/docs/current/sql-createtype.html
9.2 version mentioned before is outdated.
Any news for this feature?
Have a same issue in HeidiSQL 12.6.0.6765 on Windows 10 with PostgreSQL 14.10.0
I am still seeing this on Version 12.8.0.6926 (64 Bit) for Windows 10 On PostgreSQL 13