@@ -113,54 +113,56 @@ export function stringifyWhereUnique(data: DMMF.Model) {
113113 const annotations = extractAnnotations ( data . documentation ) ;
114114 if ( annotations . isHidden ) return undefined ;
115115
116- const uniqueCompositeFields = data . uniqueFields . map ( ( fields ) => {
117- const compositeName = fields . join ( "_" ) ;
118- const fieldObjects = fields . map (
119- // biome-ignore lint/style/noNonNullAssertion: this must exist
120- ( f ) => data . fields . find ( ( field ) => field . name === f ) ! ,
121- ) ;
122-
123- const stringifiedFieldObjects = fieldObjects . map ( ( f ) => {
124- const annotations = extractAnnotations ( f . documentation ) ;
125- if ( annotations . isHidden ) return undefined ;
126- let stringifiedType = "" ;
127-
128- if ( isPrimitivePrismaFieldType ( f . type ) ) {
129- const overwrittenType = annotations . annotations
130- . filter ( isTypeOverwriteVariant )
131- . at ( 0 ) ?. value ;
132-
133- if ( overwrittenType ) {
134- stringifiedType = overwrittenType ;
116+ const uniqueCompositeFields = data . uniqueFields
117+ . filter ( ( fields ) => fields . length > 1 )
118+ . map ( ( fields ) => {
119+ const compositeName = fields . join ( "_" ) ;
120+ const fieldObjects = fields . map (
121+ // biome-ignore lint/style/noNonNullAssertion: this must exist
122+ ( f ) => data . fields . find ( ( field ) => field . name === f ) ! ,
123+ ) ;
124+
125+ const stringifiedFieldObjects = fieldObjects . map ( ( f ) => {
126+ const annotations = extractAnnotations ( f . documentation ) ;
127+ if ( annotations . isHidden ) return undefined ;
128+ let stringifiedType = "" ;
129+
130+ if ( isPrimitivePrismaFieldType ( f . type ) ) {
131+ const overwrittenType = annotations . annotations
132+ . filter ( isTypeOverwriteVariant )
133+ . at ( 0 ) ?. value ;
134+
135+ if ( overwrittenType ) {
136+ stringifiedType = overwrittenType ;
137+ } else {
138+ stringifiedType = stringifyPrimitiveType ( {
139+ fieldType : f . type as PrimitivePrismaFieldType ,
140+ options : generateTypeboxOptions ( {
141+ exludeAdditionalProperties : false ,
142+ input : annotations ,
143+ } ) ,
144+ } ) ;
145+ }
146+ } else if ( processedEnums . find ( ( e ) => e . name === f . type ) ) {
147+ // biome-ignore lint/style/noNonNullAssertion: we checked this manually
148+ stringifiedType = processedEnums . find (
149+ ( e ) => e . name === f . type ,
150+ ) ! . stringRepresentation ;
135151 } else {
136- stringifiedType = stringifyPrimitiveType ( {
137- fieldType : f . type as PrimitivePrismaFieldType ,
138- options : generateTypeboxOptions ( {
139- exludeAdditionalProperties : false ,
140- input : annotations ,
141- } ) ,
142- } ) ;
152+ throw new Error ( "Invalid type for unique composite generation" ) ;
143153 }
144- } else if ( processedEnums . find ( ( e ) => e . name === f . type ) ) {
145- // biome-ignore lint/style/noNonNullAssertion: we checked this manually
146- stringifiedType = processedEnums . find (
147- ( e ) => e . name === f . type ,
148- ) ! . stringRepresentation ;
149- } else {
150- throw new Error ( "Invalid type for unique composite generation" ) ;
151- }
152154
153- return `${ f . name } : ${ stringifiedType } ` ;
154- } ) ;
155+ return `${ f . name } : ${ stringifiedType } ` ;
156+ } ) ;
155157
156- const compositeObject = `${
157- getConfig ( ) . typeboxImportVariableName
158- } .Object({${ stringifiedFieldObjects . join (
159- "," ,
160- ) } }, ${ generateTypeboxOptions ( { exludeAdditionalProperties : true } ) } )`;
158+ const compositeObject = `${
159+ getConfig ( ) . typeboxImportVariableName
160+ } .Object({${ stringifiedFieldObjects . join (
161+ "," ,
162+ ) } }, ${ generateTypeboxOptions ( { exludeAdditionalProperties : true } ) } )`;
161163
162- return `${ compositeName } : ${ compositeObject } ` ;
163- } ) ;
164+ return `${ compositeName } : ${ compositeObject } ` ;
165+ } ) ;
164166
165167 const allFields = data . fields
166168 . map ( ( field ) => {
0 commit comments