You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First off, I want to express my gratitude for maintaining this fantastic tool.
Motivation
We would like to represent PostgreSQL enums as literal unions in TypeScript. This improvement would enhance type safety and effectiveness by properly mapping PostgreSQL enums to TypeScript literal union types
Go version of sqlc already has enum type support.
Example
A sample implementation was accidentally submitted as a Pull Request. Although it was closed, it serves as a starting point for discussion. You can view the PR here: #31.
-- schema.sqlCREATETYPEauthors_roleAS ENUM ('admin', 'guest');
CREATETABLEauthors (
id BIGSERIALPRIMARY KEY,
name textNOT NULL,
bio text,
role authors_role
);
-- query.sql-- name: GetAuthor :oneSELECT*FROM authors
WHERE id = $1LIMIT1;
exportconstgetAuthorQuery=`-- name: GetAuthor :oneSELECT id, name, bio, role FROM authorsWHERE id = $1 LIMIT 1`;exportinterfaceGetAuthorArgs{id: string;name: string;bio: string|null;role: "admin"|"guest"|null;}
Improvement Points
The current implementation doesn't support mapping to TypeScript's enum type.
The current implementation doesn't create explicit type aliases.
Thanks.
The text was updated successfully, but these errors were encountered:
sa2taka
changed the title
Feature Request: PostgreSQL Enum Support
feat(postgres): Enum Support
Jun 23, 2024
First off, I want to express my gratitude for maintaining this fantastic tool.
Motivation
We would like to represent PostgreSQL enums as literal unions in TypeScript. This improvement would enhance type safety and effectiveness by properly mapping PostgreSQL enums to TypeScript literal union types
Go version of sqlc already has enum type support.
Example
A sample implementation was accidentally submitted as a Pull Request. Although it was closed, it serves as a starting point for discussion. You can view the PR here: #31.
Improvement Points
Thanks.
The text was updated successfully, but these errors were encountered: