Skip to content

Commit

Permalink
fix: fix column type that has defaultTo
Browse files Browse the repository at this point in the history
  • Loading branch information
subframe7536 committed Jan 30, 2025
1 parent 89f68dd commit 97a03da
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/schema/define.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,5 @@ export const column = {
*/
object: <T extends object, DefaultTo extends T | RawBuilder<unknown> | null, NotNull extends boolean | null>(
options?: Options<T, DefaultTo, NotNull>,
) => parse(DataType.object, options as any) as ColumnBuilder<TDataType['object'], T, NotNull>,
) => parse(DataType.object, options as any) as ColumnBuilder<TDataType['object'], DefaultTo, NotNull>,
}
8 changes: 2 additions & 6 deletions src/schema/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,8 @@ export type InferTable<
: P[K]['type'] extends TDataType['increments']
// return "Generated<...>"
? Exclude<P[K]['defaultTo'], null>
// if defaultTo is not null
: IsNotNull<P[K]['defaultTo']> extends true
// return Generated
? Generated<Exclude<P[K]['defaultTo'], null>>
// return optional
: P[K]['defaultTo'] | null
// return defaultTo
: P[K]['defaultTo'] | null
// return error info
: `TypeError: [defaultTo] is not satisfied [type] in column "${K & string}"`
}>
Expand Down

0 comments on commit 97a03da

Please sign in to comment.