Skip to content

ergonomics: .column should default to 0 | 1 unless nonNull: false - #84

Merged
ryanrasti merged 2 commits into
mainfrom
ryan_column_auto_null
Jul 14, 2026
Merged

ergonomics: .column should default to 0 | 1 unless nonNull: false#84
ryanrasti merged 2 commits into
mainfrom
ryan_column_auto_null

Conversation

@ryanrasti

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates typegres’s column-descriptor typing so Type.column() derives the returned instance’s nullability from { nonNull: true } (or lack thereof), eliminating the need to use TS generic instantiation expressions like (Text<1>).column(...) in user code and generated table code.

Changes:

  • Teach SqlValue.column() to return the type’s __nonNullable vs __nullable variant based on opts.nonNull.
  • Add __nullable / __nonNullable metadata to the dialect root Any overrides (PG + SQLite) so the new column() typing works uniformly.
  • Update table codegen and tests/examples to emit and use Type.column(...) instead of (Type<N>).column(...).

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/types/sqlite/overrides/any.ts Adds __nullable / __nonNullable to SQLite root Any metadata.
src/types/sql-value.ts Updates SqlValue.column() return type to derive nullability from opts.nonNull.
src/types/postgres/overrides/any.ts Adds __nullable / __nonNullable to Postgres root Any metadata.
src/types/postgres/index.test.ts Adjusts type-level column tests to use Type.column(...) directly.
src/tables/sqlite.test.ts Updates generated SQLite table snapshots to the new column emission style.
src/tables/postgres.test.ts Updates generated Postgres table snapshots to the new column emission style.
src/tables/generate.ts Changes codegen to emit ${Type}.column(...) (drops <N> instantiation).
src/tables/generate.test.ts Updates codegen tests’ expected output for the new column emission style.
src/table.test.ts Updates inline table definitions to use Type.column(...).
src/scope.test.ts Updates scope tests’ table definitions to use Type.column(...).
src/rpc-exoeval.test.ts Updates RPC test table definitions to use Type.column(...).
src/rpc-capnweb.test.ts Updates RPC test table definitions to use Type.column(...).
src/live/iteration.test.ts Updates live-iteration test table definitions to use Type.column(...).
src/live/extractor.test.ts Updates extractor tests’ table definitions to use Type.column(...).
src/live/events.test.ts Updates live-events test table definitions to use Type.column(...).
src/live/db-live.test.ts Updates db-live test table definitions to use Type.column(...).
src/hydrate.test.ts Updates hydrate test table definitions to use Type.column(...).
src/demo/demo.ts Updates demo table definition to use Type.column(...).
src/database.test.ts Updates transaction tests’ table definitions to use Type.column(...).
src/builder/update.test.ts Updates update-builder tests’ table definitions to use Type.column(...).
src/builder/query.test.ts Updates query-builder tests’ table definitions to use Type.column(...).
src/builder/insert.test.ts Updates insert-builder tests’ table definitions to use Type.column(...).
src/builder/delete.test.ts Updates delete-builder tests’ table definitions to use Type.column(...).
examples/sqlite/src/tables/teams.ts Updates SQLite example generated tables to use Type.column(...).
examples/sqlite/src/tables/dogs.ts Updates SQLite example generated tables to use Type.column(...).
examples/basic/src/tables/toys.ts Updates basic example generated tables to use Type.column(...).
examples/basic/src/tables/teams.ts Updates basic example generated tables to use Type.column(...).
examples/basic/src/tables/microchips.ts Updates basic example generated tables to use Type.column(...).
examples/basic/src/tables/dogs.ts Updates basic example generated tables to use Type.column(...).
examples/basic/src/tables/collars.ts Updates basic example generated tables to use Type.column(...).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ryanrasti
ryanrasti force-pushed the ryan_column_auto_null branch from 1b3f31c to 13d26ed Compare July 14, 2026 22:46
@ryanrasti ryanrasti changed the title feat(types): .column derives nullability from nonNull — drop the <N>instantiation ergonomics: .column should default to 0 | 1 unless nonNull: false Jul 14, 2026
@ryanrasti
ryanrasti merged commit bce8986 into main Jul 14, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants