File tree Expand file tree Collapse file tree 2 files changed +14
-9
lines changed Expand file tree Collapse file tree 2 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -1481,8 +1481,9 @@ describe('Cloud Code', () => {
1481
1481
1482
1482
it ( 'beforeSave should not sanitize database' , async done => {
1483
1483
let count = 0 ;
1484
- Parse . Cloud . beforeSave ( 'CloudIncrementNested' , ( ) => {
1484
+ Parse . Cloud . beforeSave ( 'CloudIncrementNested' , req => {
1485
1485
count += 1 ;
1486
+ expect ( typeof req . object . get ( 'objectField' ) . number ) . toBe ( 'number' ) ;
1486
1487
} ) ;
1487
1488
1488
1489
const obj = new Parse . Object ( 'CloudIncrementNested' ) ;
Original file line number Diff line number Diff line change @@ -1558,15 +1558,19 @@ RestWrite.prototype.buildUpdatedObject = function (extraData) {
1558
1558
const updatedObject = triggers . inflate ( extraData , this . originalData ) ;
1559
1559
Object . keys ( this . data ) . reduce ( function ( data , key ) {
1560
1560
if ( key . indexOf ( '.' ) > 0 ) {
1561
- // subdocument key with dot notation ('x.y':v => 'x':{'y':v})
1562
- const splittedKey = key . split ( '.' ) ;
1563
- const parentProp = splittedKey [ 0 ] ;
1564
- let parentVal = updatedObject . get ( parentProp ) ;
1565
- if ( typeof parentVal !== 'object' ) {
1566
- parentVal = { } ;
1561
+ if ( typeof data [ key ] . __op === 'string' ) {
1562
+ updatedObject . set ( key , data [ key ] ) ;
1563
+ } else {
1564
+ // subdocument key with dot notation { 'x.y': v } => { 'x': { 'y' : v } })
1565
+ const splittedKey = key . split ( '.' ) ;
1566
+ const parentProp = splittedKey [ 0 ] ;
1567
+ let parentVal = updatedObject . get ( parentProp ) ;
1568
+ if ( typeof parentVal !== 'object' ) {
1569
+ parentVal = { } ;
1570
+ }
1571
+ parentVal [ splittedKey [ 1 ] ] = data [ key ] ;
1572
+ updatedObject . set ( parentProp , parentVal ) ;
1567
1573
}
1568
- parentVal [ splittedKey [ 1 ] ] = data [ key ] ;
1569
- updatedObject . set ( parentProp , parentVal ) ;
1570
1574
delete data [ key ] ;
1571
1575
}
1572
1576
return data ;
You can’t perform that action at this time.
0 commit comments