supabase / postgres-meta

A RESTful API for managing your Postgres. Fetch tables, add roles, and run queries
https://supabase.com
Apache License 2.0
856 stars 112 forks source link

Composite types can be null #763

Open 0xBigBoss opened 2 months ago

0xBigBoss commented 2 months ago

Bug report

Describe the bug

This PR introduced support for composite types, https://github.com/supabase/postgres-meta/pull/459. However, composite type fields can be null.

The syntax is comparable to CREATE TABLE, except that only field names and types can be specified; no constraints (such as NOT NULL) can presently be included. Note that the AS keyword is essential; without it, the system will think a different kind of CREATE TYPE command is meant, and you will get odd syntax errors. ^1

Composite type declaration field type values then should output with a | null.

An aside: it would also be nice to have support for domains, currently they are generated as unknown type.

drop type t;

create domain notnullint as int not null;

create type t as (a int, b notnullint);

select (1,2)::t;
-- (1,2)

select (1,null)::t;
-- [2024-04-24 09:54:44] [23502] ERROR: domain notnullint does not allow null values
Screenshot 2024-04-24 at 09 57 34