File tree Expand file tree Collapse file tree 2 files changed +29
-4
lines changed Expand file tree Collapse file tree 2 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,34 @@ describe('Parse Relation', () => {
43
43
} ) ;
44
44
} ) ;
45
45
46
+ it ( 'can do consecutive adds (#2056)' , done => {
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
+ parent . save ( ) . then ( parentAgain => {
54
+ Parse . Object . saveAll ( childObjects )
55
+ . then ( ( ) => {
56
+ for ( const child of childObjects ) {
57
+ parentAgain . relation ( 'child' ) . add ( child ) ;
58
+ }
59
+ return parentAgain . save ( ) ;
60
+ } )
61
+ . then ( ( ) => {
62
+ return parentAgain . relation ( 'child' ) . query ( ) . find ( ) ;
63
+ } )
64
+ . then ( results => {
65
+ assert . equal ( results . length , 2 ) ;
66
+ const expectedIds = new Set ( childObjects . map ( r => r . id ) ) ;
67
+ const foundIds = new Set ( results . map ( r => r . id ) ) ;
68
+ assert . deepEqual ( expectedIds , foundIds ) ;
69
+ done ( ) ;
70
+ } ) ;
71
+ } ) ;
72
+ } ) ;
73
+
46
74
it ( 'can query relation without schema' , done => {
47
75
const ChildObject = Parse . Object . extend ( 'ChildObject' ) ;
48
76
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