Skip to content

Commit 36d5575

Browse files
committed
fix(orm): use mapped type instead of Capitalize for ExtResultBase model keys
Iterate over GetModels<Schema> directly and remap keys with Uncapitalize, instead of Uncapitalizing first and round-tripping with Capitalize. This fixes breakage when model names start with a lowercase letter, since Uncapitalize followed by Capitalize is not lossless (e.g. myModel -> myModel -> MyModel, which no longer matches the schema key).
1 parent 046e6c9 commit 36d5575

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/orm/src/client/plugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ export type ExtResultFieldDef<Needs extends Record<string, true> = Record<string
4141
* `needs` keys are constrained to non-relation fields of the corresponding model.
4242
*/
4343
export type ExtResultBase<Schema extends SchemaDef = SchemaDef> = {
44-
[M in Uncapitalize<GetModels<Schema>>]?: Record<
44+
[M in GetModels<Schema> as Uncapitalize<M>]?: Record<
4545
string,
4646
{
47-
needs: Partial<Record<NonRelationFields<Schema, Capitalize<M> & GetModels<Schema>>, true>>;
47+
needs: Partial<Record<NonRelationFields<Schema, M>, true>>;
4848
compute: (...args: any[]) => any;
4949
}
5050
>;

0 commit comments

Comments
 (0)