Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(lix sdk) use null | T instead of undefined | T #55

Open
samuelstroschein opened this issue Aug 26, 2024 — with Linear · 1 comment
Open

(lix sdk) use null | T instead of undefined | T #55

samuelstroschein opened this issue Aug 26, 2024 — with Linear · 1 comment

Comments

Copy link
Member

Context

kysely-org/kysely#27 (comment)

Proposal

Define database schema types as null | T instead of undefined | T to avoid bugs.

Copy link
Member Author

Using T | null leads to breaking changes for newly added (optional) columns.

Here is a reproduction https://www.typescriptlang.org/play/?#code/C4TwDgpgBAcgrgGwQQwEYIgFTRqBeKAbwCgBIAE2WGQC4oBBAJ0eRACE4AzTiRgbjIBbCNUrU6AJQgBjAPaNyAHgDOwRgEsAdgHMANFGSaQAPigAfKJsQIBAXwHFQkKAFVN5CJy04sP-ETIxWgZmVg5uXgFSYVEqZAB+SRl5JVUNHX1DEzsHOU1VKGp0CHgkHzpSlGLsYv8SCji6TQgAdxCWdi4eRgAKAAYASl1ie2JiPIKijDcPL01y13dPb2q-Anqgptb2sK7efqGR3Nl82QwAOgRZbR6pkusffTuZ5fnigaA.

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

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

No branches or pull requests

1 participant