Add MariaDB queue table. Fix Bugs
This commit is contained in:
Vendored
+5
-1
@@ -2,6 +2,7 @@ import dbHandler from "../db-handler";
|
||||
import _ from "lodash";
|
||||
import sqlGenerator from "../../utils/sql-generator";
|
||||
import { quoteIdentifier } from "../../utils/sql-identifier";
|
||||
import { isQueueTable, QUEUE_NOT_CLAIMED_SQL } from "../queue/queue-utils";
|
||||
export default async function DbDelete({ table, query, targetId, config, }) {
|
||||
let sqlObj = null;
|
||||
try {
|
||||
@@ -11,7 +12,7 @@ export default async function DbDelete({ table, query, targetId, config, }) {
|
||||
genObject: finalQuery,
|
||||
targetId,
|
||||
});
|
||||
const whereClause = sqlObj.where;
|
||||
let whereClause = sqlObj.where;
|
||||
if (!whereClause) {
|
||||
return {
|
||||
success: false,
|
||||
@@ -21,6 +22,9 @@ export default async function DbDelete({ table, query, targetId, config, }) {
|
||||
},
|
||||
};
|
||||
}
|
||||
if (isQueueTable(table)) {
|
||||
whereClause += ` AND ${QUEUE_NOT_CLAIMED_SQL}`;
|
||||
}
|
||||
let sql = `DELETE FROM ${quoteIdentifier(table)} ${whereClause}`;
|
||||
sql += ` RETURNING *`;
|
||||
sqlObj.string = sql;
|
||||
|
||||
Vendored
+4
@@ -2,9 +2,13 @@ import dbHandler from "../db-handler";
|
||||
import sqlInsertGenerator from "../../utils/sql-insert-generator";
|
||||
import { sanitizeHtmlFieldsBatch } from "../../utils/sanitize-html-fields";
|
||||
import grabDuplicateSafeInsertSql from "../grab-duplicate-safe-insert-sql";
|
||||
import { assertNoProtectedQueueFields, isQueueTable, } from "../queue/queue-utils";
|
||||
export default async function DbInsert({ table, data, update_on_duplicate, config, }) {
|
||||
let sqlObj = null;
|
||||
try {
|
||||
if (isQueueTable(table)) {
|
||||
assertNoProtectedQueueFields(table, data);
|
||||
}
|
||||
const sanitizedData = sanitizeHtmlFieldsBatch({
|
||||
table,
|
||||
data,
|
||||
|
||||
Vendored
+6
-1
@@ -4,6 +4,7 @@ import sanitizeHtmlFields from "../../utils/sanitize-html-fields";
|
||||
import { quoteIdentifier } from "../../utils/sql-identifier";
|
||||
import sqlValuePlaceholder from "../../utils/sql-value-placeholder";
|
||||
import grabTableFields from "../../utils/grab-table-fields";
|
||||
import { assertNoProtectedQueueFields, isQueueTable, QUEUE_NOT_CLAIMED_SQL, } from "../queue/queue-utils";
|
||||
/** Thrown inside the transaction to roll back and return a response */
|
||||
class UpdateAbort extends Error {
|
||||
response;
|
||||
@@ -26,13 +27,17 @@ export default async function DbUpdate({ table, data, query, targetId, config, }
|
||||
genObject: finalQuery,
|
||||
targetId,
|
||||
});
|
||||
const whereClause = sqlQueryObj.where;
|
||||
let whereClause = sqlQueryObj.where;
|
||||
if (!whereClause) {
|
||||
return {
|
||||
success: false,
|
||||
msg: `No WHERE clause`,
|
||||
};
|
||||
}
|
||||
if (isQueueTable(table)) {
|
||||
assertNoProtectedQueueFields(table, [data]);
|
||||
whereClause += ` AND ${QUEUE_NOT_CLAIMED_SQL}`;
|
||||
}
|
||||
const sanitizedData = sanitizeHtmlFields({
|
||||
table,
|
||||
data,
|
||||
|
||||
Reference in New Issue
Block a user