Skip to content

Columns get a null value added to their type even when notNull is specified #51

@cschmatzler

Description

@cschmatzler

My table:

export const role = pgEnum("role", ["owner", "admin", "user", "viewer"]);
export const users = pgTable("users", {
  ...id,
  email: varchar("email", { length: 255 }).notNull(),
  name: varchar("name", { length: 255 }),
  workspaceID: char("workspace_id", { length: 26 + 4 })
    .references(() => workspaces.id)
    .notNull(),
  role: role("role").default("user").notNull(),
  lastSeen: timestamp("last_seen"),
}, table => [uniqueIndex("user_email_workspaceID_idx").on(table.email, table.workspaceID)]);

typeof users.$inferSelect equals

{
    role: "owner" | "admin" | "user" | "viewer";
    id: string;
    name: string | null;
    email: string;
    workspaceID: string;
    lastSeen: Date | null;
}

but Row<typeof schema.tables.users> equals

{
    readonly id: string;
    readonly email: string;
    readonly name: string | null;
    readonly workspaceID: string;
    readonly role: "owner" | "admin" | "user" | "viewer" | null;
    readonly lastSeen: 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