Skip to content

Commit 9be5a80

Browse files
committed
Preserve optionality on columns in selectors and aggregates.
1 parent e06c168 commit 9be5a80

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/map2.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,14 @@ type ValidColumnFilterTypes<M extends Record<string, TableDefinition<M>>, K exte
209209

210210
// Column selection refs without filter methods - only for getting values/references
211211
type ColumnSelectionRefs<M extends Record<string, TableDefinition<M>>, K extends keyof M> = {
212-
[C in keyof M[K]['columns']]: M[K]['columns'][C];
212+
// Required columns (notNull = true)
213+
[C in keyof M[K]['columns'] as IsRequired<M[K]['columns'][C]> extends true ? C : never]: ColumnTypeToTS<M[K]['columns'][C]>;
214+
} & {
215+
// Optional columns (nullable)
216+
[C in keyof M[K]['columns'] as IsRequired<M[K]['columns'][C]> extends true ? never : C]?: ColumnTypeToTS<M[K]['columns'][C]> | null | undefined;
213217
};
214218

219+
215220
// Relation selection refs without filter methods - supports deep nesting
216221
// In selectors, all relation types just provide access to the target table structure
217222
// But WITHOUT aggregate functions (only available at root level)

0 commit comments

Comments
 (0)