@saltcorn/data 1.3.0-beta.12 → 1.3.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base-plugin/actions.d.ts.map +1 -1
- package/dist/base-plugin/actions.js +21 -9
- package/dist/base-plugin/actions.js.map +1 -1
- package/dist/base-plugin/viewtemplates/filter.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/filter.js +9 -3
- package/dist/base-plugin/viewtemplates/filter.js.map +1 -1
- package/dist/models/file.d.ts +0 -1
- package/dist/models/file.d.ts.map +1 -1
- package/dist/models/model_instance.d.ts +0 -1
- package/dist/models/model_instance.d.ts.map +1 -1
- package/dist/models/table.d.ts.map +1 -1
- package/dist/models/table.js +44 -29
- package/dist/models/table.js.map +1 -1
- package/package.json +11 -11
package/dist/models/table.js
CHANGED
|
@@ -836,39 +836,54 @@ class Table {
|
|
|
836
836
|
}
|
|
837
837
|
}
|
|
838
838
|
}
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
839
|
+
await db_1.default.tryCatchInTransaction(async () => {
|
|
840
|
+
if (rows) {
|
|
841
|
+
const delIds = rows.map((r) => r[this.pk_name]);
|
|
842
|
+
if (!db_1.default.isSQLite) {
|
|
843
|
+
await db_1.default.deleteWhere(this.name, {
|
|
844
|
+
[this.pk_name]: { in: delIds },
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
else {
|
|
848
|
+
await db_1.default.query(`delete from "${db_1.default.sqlsanitize(this.name)}" where "${db_1.default.sqlsanitize(this.pk_name)}" in (${delIds.join(",")})`);
|
|
849
|
+
}
|
|
850
|
+
for (const row of rows)
|
|
851
|
+
await this.auto_update_calc_aggregations(row);
|
|
852
|
+
if (this.has_sync_info) {
|
|
853
|
+
const dbTime = await db_1.default.time();
|
|
854
|
+
await this.addDeleteSyncInfo(rows, dbTime);
|
|
855
|
+
}
|
|
845
856
|
}
|
|
846
857
|
else {
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
858
|
+
const delIds = this.has_sync_info
|
|
859
|
+
? await db_1.default.select(this.name, where, {
|
|
860
|
+
fields: [this.pk_name],
|
|
861
|
+
})
|
|
862
|
+
: null;
|
|
863
|
+
await db_1.default.deleteWhere(this.name, where);
|
|
864
|
+
if (this.has_sync_info) {
|
|
865
|
+
const dbTime = await db_1.default.time();
|
|
866
|
+
await this.addDeleteSyncInfo(delIds, dbTime);
|
|
867
|
+
}
|
|
854
868
|
}
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
869
|
+
//if (fields.find((f) => f.primary_key)) await this.resetSequence();
|
|
870
|
+
for (const file of deleteFiles) {
|
|
871
|
+
await file.delete();
|
|
872
|
+
}
|
|
873
|
+
}, (e) => {
|
|
874
|
+
if (+e.code == 23503 && e.table) {
|
|
875
|
+
const table = Table.findOne(e.table);
|
|
876
|
+
const field = table?.fields.find((f) => f.reftable_name === this.name && f.attributes.fkey_error_msg);
|
|
877
|
+
// TODO there could in theory be multiple key fields onto this table.
|
|
878
|
+
// check if e.constraint matches tableName_fieldName_fkey. if yes that is field
|
|
879
|
+
if (field)
|
|
880
|
+
throw new Error(field.attributes.fkey_error_msg);
|
|
881
|
+
else
|
|
882
|
+
throw e;
|
|
866
883
|
}
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
await file.delete();
|
|
871
|
-
}
|
|
884
|
+
else
|
|
885
|
+
throw e;
|
|
886
|
+
});
|
|
872
887
|
}
|
|
873
888
|
/**
|
|
874
889
|
* Returns row with only fields that can be read from db (readFromDB flag)
|