Make all properties of InsertType optional for DB schema compatibility#169
Merged
andrewzolotukhin merged 1 commit intodevelopmentfrom Apr 14, 2026
Merged
Make all properties of InsertType optional for DB schema compatibility#169andrewzolotukhin merged 1 commit intodevelopmentfrom
andrewzolotukhin merged 1 commit intodevelopmentfrom
Conversation
…ility with generated DB schemas
Contributor
There was a problem hiding this comment.
Pull request overview
Adjusts @cleverbrush/knex-schema’s InsertType helper to better match DB-driven insert scenarios where some fields may be generated by the database (e.g., auto-increment IDs), by making insert-input properties optional.
Changes:
- Redefines
InsertType<T>to infer fromT.makeAllPropsOptional()instead ofInferType<T>. - Updates the inline documentation comment for
InsertType.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export type InsertType< | ||
| T extends ObjectSchemaBuilder<any, any, any, any, any, any, any> | ||
| > = InferType<T>; | ||
| > = InferType<ReturnType<T['makeAllPropsOptional']>>; |
Comment on lines
+190
to
+194
| // InsertType — all properties optional (DB may generate some, e.g. SERIAL id) | ||
| // --------------------------------------------------------------------------- | ||
| export type InsertType< | ||
| T extends ObjectSchemaBuilder<any, any, any, any, any, any, any> | ||
| > = InferType<T>; | ||
| > = InferType<ReturnType<T['makeAllPropsOptional']>>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…ility with generated DB schemas
Description
Type of Change
Checklist
npm run lintand fixed any issuesnpm run testand all tests passnpx changeset) if this changes package behavior