Open samuelstroschein opened 2 weeks ago
Using T | null
leads to breaking changes for newly added (optional) columns.
Adding a column to a table and marking it with null
, leads to breaking changes everywhere the type SomeTable
or Selectable<SomeTable>
is used.
type SomeTable = {
data: ArrayBuffer;
+ metadata: Record<string, any> | null;
};
Additional context
undefined
everywhere in kysely will lead to bugs down the road like an insert not being able to distinguish between null
and undefined
or JSON parsing failingnull
as harmful https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines#null-and-undefined
Context
https://github.com/kysely-org/kysely/issues/27#issuecomment-986076120
Proposal
Define database schema types as
null | T
instead ofundefined | T
to avoid bugs.