@@ -12,17 +12,14 @@ import type {
1212 GetEnum ,
1313 GetEnums ,
1414 GetModel ,
15- GetModelDiscriminator ,
1615 GetModelField ,
1716 GetModelFields ,
1817 GetModelFieldType ,
1918 GetModels ,
20- GetSubModels ,
2119 GetTypeDefField ,
2220 GetTypeDefFields ,
2321 GetTypeDefFieldType ,
2422 GetTypeDefs ,
25- IsDelegateModel ,
2623 ModelFieldIsOptional ,
2724 NonRelationFields ,
2825 RelationFields ,
@@ -62,20 +59,26 @@ export type DefaultModelResult<
6259 Optional = false ,
6360 Array = false ,
6461> = WrapType <
65- IsDelegateModel < Schema , Model > extends true
66- ? // delegate model's selection result is a union of all sub-models
67- DelegateUnionResult < Schema , Model , Options , GetSubModels < Schema , Model > , Omit >
68- : {
69- [ Key in NonRelationFields < Schema , Model > as ShouldOmitField <
70- Schema ,
71- Model ,
72- Options ,
73- Key ,
74- Omit
75- > extends true
76- ? never
77- : Key ] : MapModelFieldType < Schema , Model , Key > ;
78- } ,
62+ {
63+ [ Key in NonRelationFields < Schema , Model > as ShouldOmitField < Schema , Model , Options , Key , Omit > extends true
64+ ? never
65+ : Key ] : MapModelFieldType < Schema , Model , Key > ;
66+ } ,
67+ // TODO: revisit how to efficiently implement discriminated sub model types
68+ // IsDelegateModel<Schema, Model> extends true
69+ // ? // delegate model's selection result is a union of all sub-models
70+ // DelegateUnionResult<Schema, Model, Options, GetSubModels<Schema, Model>, Omit>
71+ // : {
72+ // [Key in NonRelationFields<Schema, Model> as ShouldOmitField<
73+ // Schema,
74+ // Model,
75+ // Options,
76+ // Key,
77+ // Omit
78+ // > extends true
79+ // ? never
80+ // : Key]: MapModelFieldType<Schema, Model, Key>;
81+ // },
7982 Optional ,
8083 Array
8184> ;
@@ -120,15 +123,15 @@ type SchemaLevelOmit<
120123 Field extends GetModelFields < Schema , Model > ,
121124> = GetModelField < Schema , Model , Field > [ 'omit' ] extends true ? true : false ;
122125
123- type DelegateUnionResult <
124- Schema extends SchemaDef ,
125- Model extends GetModels < Schema > ,
126- Options extends ClientOptions < Schema > ,
127- SubModel extends GetModels < Schema > ,
128- Omit = undefined ,
129- > = SubModel extends string // typescript union distribution
130- ? DefaultModelResult < Schema , SubModel , Options , Omit > & { [ K in GetModelDiscriminator < Schema , Model > ] : SubModel } // fixate discriminated field
131- : never ;
126+ // type DelegateUnionResult<
127+ // Schema extends SchemaDef,
128+ // Model extends GetModels<Schema>,
129+ // Options extends ClientOptions<Schema>,
130+ // SubModel extends GetModels<Schema>,
131+ // Omit = undefined,
132+ // > = SubModel extends string // typescript union distribution
133+ // ? DefaultModelResult<Schema, SubModel, Options, Omit> & { [K in GetModelDiscriminator<Schema, Model>]: SubModel } // fixate discriminated field
134+ // : never;
132135
133136type ModelSelectResult <
134137 Schema extends SchemaDef ,
@@ -1029,7 +1032,7 @@ type OppositeRelationFields<
10291032 Model extends GetModels < Schema > ,
10301033 Field extends GetModelFields < Schema , Model > ,
10311034 Opposite = OppositeRelation < Schema , Model , Field > ,
1032- > = Opposite extends RelationInfo ? ( Opposite [ 'fields' ] extends string [ ] ? Opposite [ 'fields' ] : [ ] ) : [ ] ;
1035+ > = Opposite extends RelationInfo ? ( Opposite [ 'fields' ] extends readonly string [ ] ? Opposite [ 'fields' ] : [ ] ) : [ ] ;
10331036
10341037type OppositeRelationAndFK <
10351038 Schema extends SchemaDef ,
@@ -1083,21 +1086,16 @@ export type FindArgs<
10831086 Model extends GetModels < Schema > ,
10841087 Collection extends boolean ,
10851088 AllowFilter extends boolean = true ,
1086- > =
1087- ProviderSupportsDistinct < Schema > extends true
1088- ? ( Collection extends true
1089- ? SortAndTakeArgs < Schema , Model > & {
1090- /**
1091- * Distinct fields
1092- */
1093- distinct ?: OrArray < NonRelationFields < Schema , Model > > ;
1094- }
1095- : { } ) &
1096- ( AllowFilter extends true ? FilterArgs < Schema , Model > : { } ) &
1097- SelectIncludeOmit < Schema , Model , Collection >
1098- : ( Collection extends true ? SortAndTakeArgs < Schema , Model > : { } ) &
1099- ( AllowFilter extends true ? FilterArgs < Schema , Model > : { } ) &
1100- SelectIncludeOmit < Schema , Model , Collection > ;
1089+ > = ( Collection extends true
1090+ ? SortAndTakeArgs < Schema , Model > & {
1091+ /**
1092+ * Distinct fields
1093+ */
1094+ distinct ?: OrArray < NonRelationFields < Schema , Model > > ;
1095+ }
1096+ : { } ) &
1097+ ( AllowFilter extends true ? FilterArgs < Schema , Model > : { } ) &
1098+ SelectIncludeOmit < Schema , Model , Collection > ;
11011099
11021100export type FindManyArgs < Schema extends SchemaDef , Model extends GetModels < Schema > > = FindArgs < Schema , Model , true > ;
11031101
@@ -2002,7 +2000,7 @@ type NestedDeleteManyInput<
20022000
20032001type NonOwnedRelationFields < Schema extends SchemaDef , Model extends GetModels < Schema > > = keyof {
20042002 [ Key in RelationFields < Schema , Model > as GetModelField < Schema , Model , Key > [ 'relation' ] extends {
2005- references : unknown [ ] ;
2003+ references : readonly unknown [ ] ;
20062004 }
20072005 ? never
20082006 : Key ] : true ;
@@ -2014,8 +2012,8 @@ type HasToManyRelations<Schema extends SchemaDef, Model extends GetModels<Schema
20142012 ? false
20152013 : true ;
20162014
2017- type ProviderSupportsDistinct < Schema extends SchemaDef > = Schema [ 'provider' ] [ 'type' ] extends 'postgresql'
2018- ? true
2019- : false ;
2015+ // type ProviderSupportsDistinct<Schema extends SchemaDef> = Schema['provider']['type'] extends 'postgresql'
2016+ // ? true
2017+ // : false;
20202018
20212019// #endregion
0 commit comments