@@ -817,12 +817,19 @@ export class DelegateProxyHandler extends DefaultPrismaProxyHandler {
817817 return super . updateMany ( args ) ;
818818 }
819819
820- const simpleUpdateMany = Object . keys ( args . data ) . every ( ( key ) => {
820+ let simpleUpdateMany = Object . keys ( args . data ) . every ( ( key ) => {
821821 // check if the `data` clause involves base fields
822822 const fieldInfo = resolveField ( this . options . modelMeta , this . model , key ) ;
823823 return ! fieldInfo ?. inheritedFrom ;
824824 } ) ;
825825
826+ // check if there are any `@updatedAt` fields from delegate base models
827+ if ( simpleUpdateMany ) {
828+ if ( this . getUpdatedAtFromDelegateBases ( this . model ) . length > 0 ) {
829+ simpleUpdateMany = false ;
830+ }
831+ }
832+
826833 return this . queryUtils . transaction ( this . prisma , ( tx ) =>
827834 this . doUpdateMany ( tx , this . model , args , simpleUpdateMany )
828835 ) ;
@@ -948,6 +955,13 @@ export class DelegateProxyHandler extends DefaultPrismaProxyHandler {
948955 return ! fieldInfo ?. inheritedFrom ;
949956 } ) ;
950957
958+ // check if there are any `@updatedAt` fields from delegate base models
959+ if ( simpleUpdateMany ) {
960+ if ( this . getUpdatedAtFromDelegateBases ( model ) . length > 0 ) {
961+ simpleUpdateMany = false ;
962+ }
963+ }
964+
951965 if ( simpleUpdateMany ) {
952966 // check if the `where` clause involves base fields
953967 simpleUpdateMany = Object . keys ( args . where || { } ) . every ( ( key ) => {
@@ -1058,15 +1072,9 @@ export class DelegateProxyHandler extends DefaultPrismaProxyHandler {
10581072 // if we're updating any field, we need to take care of updating `@updatedAt`
10591073 // fields inherited from delegate base models
10601074 if ( Object . keys ( data ) . length > 0 ) {
1061- const modelFields = getFields ( this . options . modelMeta , model ) ;
1062- for ( const fieldInfo of Object . values ( modelFields ) ) {
1063- if (
1064- fieldInfo . attributes ?. some ( ( attr ) => attr . name === '@updatedAt' ) &&
1065- fieldInfo . inheritedFrom &&
1066- isDelegateModel ( this . options . modelMeta , fieldInfo . inheritedFrom )
1067- ) {
1068- this . injectBaseFieldData ( model , fieldInfo , new Date ( ) , data , 'update' ) ;
1069- }
1075+ const updatedAtFields = this . getUpdatedAtFromDelegateBases ( model ) ;
1076+ for ( const fieldInfo of updatedAtFields ) {
1077+ this . injectBaseFieldData ( model , fieldInfo , new Date ( ) , data , 'update' ) ;
10701078 }
10711079 }
10721080 }
@@ -1493,5 +1501,20 @@ export class DelegateProxyHandler extends DefaultPrismaProxyHandler {
14931501 return result ;
14941502 }
14951503
1504+ private getUpdatedAtFromDelegateBases ( model : string ) {
1505+ const result : FieldInfo [ ] = [ ] ;
1506+ const modelFields = getFields ( this . options . modelMeta , model ) ;
1507+ for ( const fieldInfo of Object . values ( modelFields ) ) {
1508+ if (
1509+ fieldInfo . attributes ?. some ( ( attr ) => attr . name === '@updatedAt' ) &&
1510+ fieldInfo . inheritedFrom &&
1511+ isDelegateModel ( this . options . modelMeta , fieldInfo . inheritedFrom )
1512+ ) {
1513+ result . push ( fieldInfo ) ;
1514+ }
1515+ }
1516+ return result ;
1517+ }
1518+
14961519 // #endregion
14971520}
0 commit comments