mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
better error condition checks
This commit is contained in:
parent
8075265753
commit
bc6be44b19
@ -26,7 +26,7 @@ const LOG_ALL_QUERIES = false;
|
|||||||
});
|
});
|
||||||
|
|
||||||
function insert(tableName, rec, replace = false) {
|
function insert(tableName, rec, replace = false) {
|
||||||
const keys = Object.keys(rec);
|
const keys = Object.keys(rec || {});
|
||||||
if (keys.length === 0) {
|
if (keys.length === 0) {
|
||||||
log.error(`Can't insert empty object into table ${tableName}`);
|
log.error(`Can't insert empty object into table ${tableName}`);
|
||||||
return;
|
return;
|
||||||
@ -53,7 +53,7 @@ function replace(tableName, rec) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function upsert(tableName, primaryKey, rec) {
|
function upsert(tableName, primaryKey, rec) {
|
||||||
const keys = Object.keys(rec);
|
const keys = Object.keys(rec || {});
|
||||||
if (keys.length === 0) {
|
if (keys.length === 0) {
|
||||||
log.error(`Can't upsert empty object into table ${tableName}`);
|
log.error(`Can't upsert empty object into table ${tableName}`);
|
||||||
return;
|
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);
|
sql.replace(remoteEC.entityName, remoteEntityRow);
|
||||||
|
|
||||||
if (!localEC || localEC.utcDateChanged < remoteEC.utcDateChanged) {
|
if (!localEC || localEC.utcDateChanged < remoteEC.utcDateChanged) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user