Skip to content

Commit a25150a

Browse files
committed
order updated
1 parent d235ccc commit a25150a

3 files changed

Lines changed: 13 additions & 12 deletions

File tree

package-lock.json

Lines changed: 2 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/model/EntityContext.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export default class EntityContext {
127127

128128
if (this[isChanging]) {
129129
if (!this.raiseEvents) {
130-
this.queuePostSaveTask(() => this.saveChangesInternalWithoutEvents(options));
130+
this.queuePostSaveTask(() => this.saveChangesInternalWithoutEvents(options, Array.from(this.changeSet.getChanges())));
131131
return 0;
132132
}
133133
this.queuePostSaveTask(() => this.saveChanges(options));
@@ -140,7 +140,7 @@ export default class EntityContext {
140140
try {
141141

142142
if(!this.raiseEvents) {
143-
const rx = await this.saveChangesInternalWithoutEvents(options);
143+
const rx = await this.saveChangesInternalWithoutEvents(options, Array.from(this.changeSet.getChanges()));
144144
await tx.commit();
145145
return rx;
146146
}
@@ -178,6 +178,8 @@ export default class EntityContext {
178178

179179
const pending = [] as { status: ChangeEntry["status"], change: ChangeEntry , events: EntityEvents<any> }[];
180180

181+
const copy = [] as ChangeEntry[];
182+
181183
for (const iterator of this.changeSet.getChanges()) {
182184

183185
switch(iterator.status) {
@@ -196,6 +198,7 @@ export default class EntityContext {
196198
}
197199
pending.push({ status: iterator.status, change: iterator, events });
198200
iterator.setupInverseProperties();
201+
copy.push(iterator);
199202
continue;
200203
case "modified":
201204
await events.beforeUpdate(iterator.entity, iterator);
@@ -204,13 +207,15 @@ export default class EntityContext {
204207
}
205208
pending.push({ status: iterator.status, change: iterator, events });
206209
iterator.setupInverseProperties();
210+
copy.push(iterator);
207211
continue;
208212
case "deleted":
209213
await events.beforeDelete(iterator.entity, iterator);
210214
if (this.verifyFilters) {
211215
verificationSession.queueVerification(iterator, events);
212216
}
213217
pending.push({ status: iterator.status, change: iterator, events });
218+
copy.push(iterator);
214219
continue;
215220
}
216221
}
@@ -219,7 +224,7 @@ export default class EntityContext {
219224
await verificationSession.verifyAsync();
220225
}
221226

222-
await this.saveChangesInternalWithoutEvents(options, pending);
227+
await this.saveChangesInternalWithoutEvents(options, copy);
223228

224229
if (pending.length > 0) {
225230

@@ -241,9 +246,8 @@ export default class EntityContext {
241246

242247
}
243248

244-
private async saveChangesInternalWithoutEvents(options?: ISaveOptions, pending?:{ change: ChangeEntry }[] ) {
249+
private async saveChangesInternalWithoutEvents(options: ISaveOptions, copy: ChangeEntry [] ) {
245250
const signal = options?.signal;
246-
const copy = pending ? pending.map((x) => x.change) : Array.from(this.changeSet.getChanges()) as ChangeEntry[];
247251
const { connection } = this;
248252
for (const iterator of copy) {
249253
switch (iterator.status) {

tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"declarationMap": true,
99
"importHelpers": true,
1010
"outDir": "dist",
11+
"rootDir": "./src",
12+
"strict": false,
1113
"skipDefaultLibCheck": true,
1214
"skipLibCheck": true,
1315
"experimentalDecorators": true,

0 commit comments

Comments
 (0)