This commit is contained in:
Benjamin Toby
2025-04-23 14:21:14 +01:00
parent d78e44c98d
commit 2ad17ae682
7 changed files with 73 additions and 7 deletions
@@ -2,6 +2,7 @@ import _ from "lodash";
import serverError from "../../backend/serverError";
import runQuery, { DbContextsArray } from "../../backend/db/runQuery";
import { DSQL_DatabaseSchemaType, PostReturn } from "../../../types";
import debugLog from "../../../utils/logging/debug-log";
type Param = {
query: any;
@@ -11,6 +12,7 @@ type Param = {
dbSchema?: DSQL_DatabaseSchemaType;
dbContext?: (typeof DbContextsArray)[number];
forceLocal?: boolean;
debug?: boolean;
};
/**
@@ -24,6 +26,7 @@ export default async function apiPost({
dbSchema,
dbContext,
forceLocal,
debug,
}: Param): Promise<PostReturn> {
if (typeof query === "string" && query?.match(/^create |^alter |^drop /i)) {
return { success: false, msg: "Wrong Input" };
@@ -54,6 +57,20 @@ export default async function apiPost({
forceLocal,
});
if (debug) {
debugLog({
log: result,
addTime: true,
label: "result",
});
debugLog({
log: query,
addTime: true,
label: "query",
});
}
results = result;
if (error) throw error;