Skip to content

postgres array elements are always nullable #186

@leoschweizer

Description

@leoschweizer

When you have an array type column like the following:

CREATE TABLE foo (
    things integer[] NOT NULL
);

Postgres still allows elements of this array to be NULL (non-nullability could only be enforced through an additional check constraint).

Yet the derived types e.g. for Insertable do not reflect nullability:

things: number[] | db.Parameter<number[]> | db.DefaultType | db.SQLFragment | db.SQLFragment<any, number[] | db.Parameter<number[]> | db.DefaultType | db.SQLFragment>;

This makes types incompatible to "properly" typed domain logic types, which would look something like this:

interface Foo {
    things: Array<number | null>
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions