HeidiSQL icon indicating copy to clipboard operation
HeidiSQL copied to clipboard

Support ENUM column types in table designer and data grid on PostgreSQL

Open Setitch opened this issue 5 years ago • 11 comments

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:

  1. Create any table with any enum type

Expected behavior

  1. Show the enum type and enum options
  2. Allow edit of enum options (x)
  3. 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]

Setitch avatar Aug 11 '20 13:08 Setitch

Please retry with the latest HeidiSQL build, and also provide a valid CREATE TABLE code with an ENUM column.

ansgarbecker avatar Aug 11 '20 15:08 ansgarbecker

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');

Setitch avatar Aug 12 '20 07:08 Setitch

Do you need any help with this issue? Anything i can help you with?

Setitch avatar Aug 13 '20 08:08 Setitch

So PostgreSQL allows creating a custom enumeration which you can use as a data type?

ansgarbecker avatar Aug 13 '20 08:08 ansgarbecker

Yes (for me its stupid thought) but there are some nice things about it too.

  1. Posgtres allows to create type with validation, enums etc
  2. It is named in one namespace
  3. several tables/fields in table can reuse the same enum
  4. adding values to enum is simple, removing - harder
  5. deleting table do not remove the custom type
  6. 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

Setitch avatar Aug 13 '20 09:08 Setitch

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].

Setitch avatar Aug 13 '20 10:08 Setitch

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.

pashagolub avatar Sep 01 '20 00:09 pashagolub

Any news for this feature?

moninformateur avatar Dec 15 '21 02:12 moninformateur

Have a same issue in HeidiSQL 12.6.0.6765 on Windows 10 with PostgreSQL 14.10.0

oleksvot avatar Feb 28 '24 21:02 oleksvot

I am still seeing this on Version 12.8.0.6926 (64 Bit) for Windows 10 On PostgreSQL 13

AntonioCS avatar Aug 28 '24 12:08 AntonioCS