File tree Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,26 @@ describe('Parse Relation', () => {
43
43
} ) ;
44
44
} ) ;
45
45
46
+ it ( 'can do consecutive adds (#2056)' , async ( ) => {
47
+ const ChildObject = Parse . Object . extend ( 'ChildObject' ) ;
48
+ const childObjects = [ ] ;
49
+ for ( let i = 0 ; i < 2 ; i ++ ) {
50
+ childObjects . push ( new ChildObject ( { x : i } ) ) ;
51
+ }
52
+ const parent = new Parse . Object ( 'ParentObject' ) ;
53
+ await parent . save ( ) ;
54
+ await Parse . Object . saveAll ( childObjects ) ;
55
+ for ( const child of childObjects ) {
56
+ parent . relation ( 'child' ) . add ( child ) ;
57
+ }
58
+ await parent . save ( ) ;
59
+ const results = await parent . relation ( 'child' ) . query ( ) . find ( ) ;
60
+ assert . equal ( results . length , 2 ) ;
61
+ const expectedIds = new Set ( childObjects . map ( r => r . id ) ) ;
62
+ const foundIds = new Set ( results . map ( r => r . id ) ) ;
63
+ assert . deepEqual ( expectedIds , foundIds ) ;
64
+ } ) ;
65
+
46
66
it ( 'can query relation without schema' , done => {
47
67
const ChildObject = Parse . Object . extend ( 'ChildObject' ) ;
48
68
const childObjects = [ ] ;
Original file line number Diff line number Diff line change @@ -50,12 +50,9 @@ class ParseRelation {
50
50
if ( this . parent . id !== parent . id ) {
51
51
throw new Error ( 'Internal Error. Relation retrieved from two different Objects.' ) ;
52
52
}
53
- } else if ( parent . id ) {
54
- this . parent = parent ;
55
53
}
56
- } else {
57
- this . parent = parent ;
58
54
}
55
+ this . parent = parent ;
59
56
}
60
57
61
58
/**
You can’t perform that action at this time.
0 commit comments