Skip to content

Commit

Permalink
Merge pull request #3742 from drizzle-team/allow-undefined-for-optionals
Browse files Browse the repository at this point in the history
exactOptionalPropertyTypes improvements (issue #2742)
  • Loading branch information
AndriiSherman authored Dec 11, 2024
2 parents e14a5a2 + 5dc5b05 commit f94b02b
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 23 deletions.
3 changes: 2 additions & 1 deletion drizzle-orm/src/mysql-core/query-builders/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export type MySqlUpdateSetSource<TTable extends MySqlTable> =
& {
[Key in keyof TTable['$inferInsert']]?:
| GetColumnData<TTable['_']['columns'][Key], 'query'>
| SQL;
| SQL
| undefined;
}
& {};

Expand Down
3 changes: 2 additions & 1 deletion drizzle-orm/src/pg-core/query-builders/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export type PgUpdateSetSource<TTable extends PgTable> =
[Key in keyof TTable['$inferInsert']]?:
| GetColumnData<TTable['_']['columns'][Key]>
| SQL
| PgColumn;
| PgColumn
| undefined;
}
& {};

Expand Down
43 changes: 25 additions & 18 deletions drizzle-orm/src/relations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,22 +214,27 @@ export type DBQueryConfig<
TTableConfig extends TableRelationalConfig = TableRelationalConfig,
> =
& {
columns?: {
[K in keyof TTableConfig['columns']]?: boolean;
};
with?: {
[K in keyof TTableConfig['relations']]?:
| true
| DBQueryConfig<
TTableConfig['relations'][K] extends One ? 'one' : 'many',
false,
TSchema,
FindTableByDBName<
columns?:
| {
[K in keyof TTableConfig['columns']]?: boolean;
}
| undefined;
with?:
| {
[K in keyof TTableConfig['relations']]?:
| true
| DBQueryConfig<
TTableConfig['relations'][K] extends One ? 'one' : 'many',
false,
TSchema,
TTableConfig['relations'][K]['referencedTableName']
FindTableByDBName<
TSchema,
TTableConfig['relations'][K]['referencedTableName']
>
>
>;
};
| undefined;
}
| undefined;
extras?:
| Record<string, SQL.Aliased>
| ((
Expand All @@ -238,7 +243,8 @@ export type DBQueryConfig<
: TTableConfig['columns']
>,
operators: { sql: Operators['sql'] },
) => Record<string, SQL.Aliased>);
) => Record<string, SQL.Aliased>)
| undefined;
}
& (TRelationType extends 'many' ?
& {
Expand All @@ -260,11 +266,12 @@ export type DBQueryConfig<
: TTableConfig['columns']
>,
operators: OrderByOperators,
) => ValueOrArray<AnyColumn | SQL>);
limit?: number | Placeholder;
) => ValueOrArray<AnyColumn | SQL>)
| undefined;
limit?: number | Placeholder | undefined;
}
& (TIsRoot extends true ? {
offset?: number | Placeholder;
offset?: number | Placeholder | undefined;
}
: {})
: {});
Expand Down
3 changes: 2 additions & 1 deletion drizzle-orm/src/singlestore-core/query-builders/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export type SingleStoreUpdateSetSource<TTable extends SingleStoreTable> =
& {
[Key in keyof TTable['$inferInsert']]?:
| GetColumnData<TTable['_']['columns'][Key], 'query'>
| SQL;
| SQL
| undefined;
}
& {};

Expand Down
3 changes: 2 additions & 1 deletion drizzle-orm/src/sqlite-core/query-builders/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export type SQLiteUpdateSetSource<TTable extends SQLiteTable> =
[Key in keyof TTable['$inferInsert']]?:
| GetColumnData<TTable['_']['columns'][Key], 'query'>
| SQL
| SQLiteColumn;
| SQLiteColumn
| undefined;
}
& {};

Expand Down
2 changes: 1 addition & 1 deletion drizzle-orm/src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export type InferModelFromColumns<
TColumns[Key],
TConfig['override']
>
]?: GetColumnData<TColumns[Key], 'query'>;
]?: GetColumnData<TColumns[Key], 'query'> | undefined;
}
: {
[
Expand Down

0 comments on commit f94b02b

Please sign in to comment.