mirror of
https://github.com/directus/directus.git
synced 2026-04-03 03:00:39 -04:00
Check if array is empty before inserting into database (#4003)
This commit is contained in:
committed by
GitHub
parent
d1fb64223d
commit
065f7ea72a
@@ -152,7 +152,9 @@ export class ItemsService<Item extends AnyItem = AnyItem> implements AbstractSer
|
||||
delta: JSON.stringify(payloads[index]),
|
||||
}));
|
||||
|
||||
await trx.insert(revisionRecords).into('directus_revisions');
|
||||
if (revisionRecords.length > 0) {
|
||||
await trx.insert(revisionRecords).into('directus_revisions');
|
||||
}
|
||||
}
|
||||
|
||||
if (cache && env.CACHE_AUTO_PURGE) {
|
||||
@@ -350,7 +352,9 @@ export class ItemsService<Item extends AnyItem = AnyItem> implements AbstractSer
|
||||
delta: JSON.stringify(payloadWithoutAliases),
|
||||
}));
|
||||
|
||||
await trx.insert(revisionRecords).into('directus_revisions');
|
||||
if (revisionRecords.length > 0) {
|
||||
await trx.insert(revisionRecords).into('directus_revisions');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -485,7 +489,9 @@ export class ItemsService<Item extends AnyItem = AnyItem> implements AbstractSer
|
||||
item: key,
|
||||
}));
|
||||
|
||||
await trx.insert(activityRecords).into('directus_activity');
|
||||
if (activityRecords.length > 0) {
|
||||
await trx.insert(activityRecords).into('directus_activity');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user