lqs / sqlingo

💥 A lightweight DSL & ORM which helps you to write SQL in Go.
MIT License
408 stars 28 forks source link

Postgres: panic: unknown field type USER-DEFINED #23

Open veqryn opened 2 months ago

veqryn commented 2 months ago

Attempting to use the generate executable on a simple postgres database. sqlingo-gen-postgres postgresql://postgres:password@localhost:5432/dbname?sslmode=disable > ./internal/gen_models.go gives:

Generating code for tables...
panic: unknown field type USER-DEFINED

goroutine 1 [running]:
main.main()
        /Users/person/go/pkg/mod/github.com/lqs/sqlingo@v0.13.1/sqlingo-gen-postgres/main.go:12 +0x90

The database schema:

CREATE TYPE COLORS AS ENUM('red', 'green', 'blue');

CREATE TABLE accounts (
    id          BIGSERIAL PRIMARY KEY,
    name        VARCHAR(50)              NOT NULL,
    email       VARCHAR(50) UNIQUE       NOT NULL,
    active      BOOLEAN                  NOT NULL,
    fav_color   COLORS,
    fav_numbers INTEGER[],
    properties  JSONB,
    created_at  TIMESTAMP WITH TIME ZONE NOT NULL
);
VarusHsu commented 1 month ago

Sqlingo not support well to postgres many complex type so far. It's still in experimental stage. But welcome giving more ideas or advises. @veqryn