-
-
Notifications
You must be signed in to change notification settings - Fork 156
Closed
Labels
bugSomething isn't workingSomething isn't working
Milestone
Description
Describe the bug
A clear and concise description of what the bug is.
Environment (please complete the following information):
- OS: [macosx]
- Database: postgres]
- Database driver: [pq, pgx]
- Jet version [v2.9.0]
Code snippet
Query statement and model files of interest.
CREATE TYPE enumtype AS ENUM ('T1', 'T2');
Having a type like the above defined in your schema causes generate to fail with the following error:
jet: pq: more than one row returned by a subquery used as an expression
The issue is with the query here https://github.com/go-jet/jet/blob/c9e627d3336459fd8c676ee354de05601fdf5c2c/generator/postgres/query_set.go
It returns
enum.name | values
-----------+--------
enumtype | T1
enumtype | T2
I believe the query should be
SELECT t.typname as "enum.name", ARRAY_AGG(e.enumlabel) as "values" FROM pg_catalog.pg_type t JOIN pg_catalog.pg_enum e on t.oid = e.enumtypid JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace WHERE n.nspname = $1 GROUP BY t.typename;
so that you can get the correct types that are being expected here
enum.name | values
-----------+---------
enumtype | {T1,T2}
Expected behavior
A clear and concise description of what you expected to happen.
This should just work automatically
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working