gen
gen copied to clipboard
Support for uuid and CHARACTER varying[] in Postgres database
- for DDL like this:
create table companies
(
id uuid default public.uuid_generate_v4() not null constraint clients_pkey
tags character varying[] default '{}'::character varying[],
deleted_by_id uuid,
created_by_id uuid,
);
-
gen
outputs errors like:
table: companies unable to generate struct field: id type: UUID error: unknown sql type: uuid
table: companies unable to generate struct field: tags type: _VARCHAR error: unknown sql type: _varchar
table: companies unable to generate struct field: deleted_by_id type: UUID error: unknown sql type: uuid
table: companies unable to generate struct field: created_by_id type: UUID error: unknown sql type: uuid
Issues
- It seems like
gen
doesn't support theuuid
type - It seems like
gen
doesn't support theCHARACTER Varying[]
type
Suggestion
- for
uuid
, suggest to generate type asuuid.NullUUID
- for
CHARACTER varying
type Company struct {
Tags sql.NullString `gorm:"column:tags;type:VARCHAR;default:'{}';" json:"tags"`
}
@GeekEast I added uuid support for postgres handling it as a string - Looking into CHARACTER varying
CREATE TABLE order_details (
order_id smallint NOT NULL,
product_id smallint NOT NULL,
unit_price real NOT NULL,
quantity smallint NOT NULL,
discount real NOT NULL
);
It seems like gen doesn't support the real
type of Postgresql
table: order_details unable to generate struct field: unit_price type: FLOAT4 error: unknown sql type: float4
table: order_details unable to generate struct field: discount type: FLOAT4 error: unknown sql type: float4
- v0.9.23 (07/10/2020)
- Added postgres types: bigserial, serial, smallserial, bigserial, float4 to mapping.json