mirror of
https://github.com/zadam/trilium.git
synced 2025-02-24 23:13:43 +08:00
better error condition checks
This commit is contained in:
parent
8075265753
commit
bc6be44b19
2 changed files with 6 additions and 2 deletions
|
@ -26,7 +26,7 @@ const LOG_ALL_QUERIES = false;
|
|||
});
|
||||
|
||||
function insert(tableName, rec, replace = false) {
|
||||
const keys = Object.keys(rec);
|
||||
const keys = Object.keys(rec || {});
|
||||
if (keys.length === 0) {
|
||||
log.error(`Can't insert empty object into table ${tableName}`);
|
||||
return;
|
||||
|
@ -53,7 +53,7 @@ function replace(tableName, rec) {
|
|||
}
|
||||
|
||||
function upsert(tableName, primaryKey, rec) {
|
||||
const keys = Object.keys(rec);
|
||||
const keys = Object.keys(rec || {});
|
||||
if (keys.length === 0) {
|
||||
log.error(`Can't upsert empty object into table ${tableName}`);
|
||||
return;
|
||||
|
|
|
@ -59,6 +59,10 @@ function updateNormalEntity(remoteEC, remoteEntityRow, instanceId) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!remoteEntityRow) {
|
||||
throw new Error(`Empty entity row for: ${JSON.stringify(remoteEC)}`);
|
||||
}
|
||||
|
||||
sql.replace(remoteEC.entityName, remoteEntityRow);
|
||||
|
||||
if (!localEC || localEC.utcDateChanged < remoteEC.utcDateChanged) {
|
||||
|
|
Loading…
Reference in a new issue