@@ -86,7 +86,10 @@ function RestWrite(config, auth, className, query, data, originalData, clientSDK
8686 // Shared SchemaController to be reused to reduce the number of loadSchema() calls per request
8787 // Once set the schemaData should be immutable
8888 this . validSchemaController = null ;
89- this . pendingOps = { } ;
89+ this . pendingOps = {
90+ operations : null ,
91+ identifier : null ,
92+ } ;
9093}
9194
9295// A convenient method to perform all the steps of processing the
@@ -227,10 +230,13 @@ RestWrite.prototype.runBeforeSaveTrigger = function () {
227230 }
228231
229232 const { originalObject, updatedObject } = this . buildParseObjects ( ) ;
230-
233+ const identifier = updatedObject . _getStateIdentifier ( ) ;
231234 const stateController = Parse . CoreManager . getObjectStateController ( ) ;
232- const [ pending ] = stateController . getPendingOps ( updatedObject . _getStateIdentifier ( ) ) ;
233- this . pendingOps = { ...pending } ;
235+ const [ pending ] = stateController . getPendingOps ( identifier ) ;
236+ this . pendingOps = {
237+ operations : { ...pending } ,
238+ identifier,
239+ } ;
234240
235241 return Promise . resolve ( )
236242 . then ( ( ) => {
@@ -1586,7 +1592,7 @@ RestWrite.prototype.runAfterSaveTrigger = function () {
15861592 . then ( result => {
15871593 const jsonReturned = result && ! result . _toFullJSON ;
15881594 if ( jsonReturned ) {
1589- this . pendingOps = { } ;
1595+ this . pendingOps . operations = { } ;
15901596 this . response . response = result ;
15911597 } else {
15921598 this . response . response = this . _updateResponseWithData (
@@ -1690,10 +1696,9 @@ RestWrite.prototype.cleanUserAuthData = function () {
16901696} ;
16911697
16921698RestWrite . prototype . _updateResponseWithData = function ( response , data ) {
1693- const { updatedObject } = this . buildParseObjects ( ) ;
16941699 const stateController = Parse . CoreManager . getObjectStateController ( ) ;
1695- const [ pending ] = stateController . getPendingOps ( updatedObject . _getStateIdentifier ( ) ) ;
1696- for ( const key in this . pendingOps ) {
1700+ const [ pending ] = stateController . getPendingOps ( this . pendingOps . identifier ) ;
1701+ for ( const key in this . pendingOps . operations ) {
16971702 if ( ! pending [ key ] ) {
16981703 data [ key ] = this . originalData ? this . originalData [ key ] : { __op : 'Delete' } ;
16991704 this . storage . fieldsChangedByTrigger . push ( key ) ;
0 commit comments