UNPKG

mysql-all-in-one

Version:

A package that allows you to have a complete interaction with a MYSQL database, allowing to connect to the database, retrieve data and create queries.

18 lines (17 loc) 799 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.generateQueryFromPreparedStatement = void 0; const esc_val_1 = require("./esc_val"); const types_1 = require("./types"); const generateQueryFromPreparedStatement = (preparedStatement) => { let { statement, values } = preparedStatement; if (typeof statement !== "string") return ""; if ((0, types_1.isPreparedStatement)(statement)) return statement || ""; statement = `${statement.split(";").join("")};`; const pieces = statement.split("?"); const firstPiece = pieces.shift(); return (pieces.reduce((acc, cur, i) => `${acc}${(0, esc_val_1.escVal)(values[i])}${cur}`, firstPiece) || ""); }; exports.generateQueryFromPreparedStatement = generateQueryFromPreparedStatement;