pqb 0.39.4 → 0.40.0
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/index.js +6 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3177,30 +3177,10 @@ const defaultSchemaConfig = {
|
|
|
3177
3177
|
timestamp: (precision) => new TimestampTZColumn(defaultSchemaConfig, precision)
|
|
3178
3178
|
};
|
|
3179
3179
|
|
|
3180
|
-
const
|
|
3181
|
-
const doubleQuoteRegex = /"/g;
|
|
3182
|
-
const quoteValue = (value) => {
|
|
3180
|
+
const quoteValue = (value, nested = false) => {
|
|
3183
3181
|
const type = typeof value;
|
|
3184
|
-
if (type === "number")
|
|
3182
|
+
if (type === "number" || type === "bigint")
|
|
3185
3183
|
return String(value);
|
|
3186
|
-
else if (type === "string")
|
|
3187
|
-
return `"${value.replace(doubleQuoteRegex, '\\"').replace(singleQuoteRegex, "''")}"`;
|
|
3188
|
-
else if (type === "boolean")
|
|
3189
|
-
return value ? "true" : "false";
|
|
3190
|
-
else if (value instanceof Date)
|
|
3191
|
-
return `"${value.toISOString()}"`;
|
|
3192
|
-
else if (Array.isArray(value))
|
|
3193
|
-
return quoteArray(value);
|
|
3194
|
-
else if (value === null || value === void 0)
|
|
3195
|
-
return "NULL";
|
|
3196
|
-
else
|
|
3197
|
-
return `"${JSON.stringify(value).replace(doubleQuoteRegex, '\\"').replace(singleQuoteRegex, "''")}"`;
|
|
3198
|
-
};
|
|
3199
|
-
const quoteArray = (array) => `'{${array.map(quoteValue).join(",")}}'`;
|
|
3200
|
-
const quote = (value) => {
|
|
3201
|
-
const type = typeof value;
|
|
3202
|
-
if (type === "number")
|
|
3203
|
-
return `${value}`;
|
|
3204
3184
|
else if (type === "string")
|
|
3205
3185
|
return quoteString(value);
|
|
3206
3186
|
else if (type === "boolean")
|
|
@@ -3208,15 +3188,14 @@ const quote = (value) => {
|
|
|
3208
3188
|
else if (value instanceof Date)
|
|
3209
3189
|
return `'${value.toISOString()}'`;
|
|
3210
3190
|
else if (Array.isArray(value))
|
|
3211
|
-
return
|
|
3191
|
+
return `${nested ? "" : "ARRAY"}[${value.map((el) => quoteValue(el, true)).join(",")}]`;
|
|
3212
3192
|
else if (value === null || value === void 0)
|
|
3213
3193
|
return "NULL";
|
|
3214
3194
|
else
|
|
3215
|
-
return
|
|
3216
|
-
};
|
|
3217
|
-
const quoteString = (value) => {
|
|
3218
|
-
return `'${value.replace(singleQuoteRegex, "''")}'`;
|
|
3195
|
+
return quoteString(JSON.stringify(value));
|
|
3219
3196
|
};
|
|
3197
|
+
const quote = (value) => quoteValue(value);
|
|
3198
|
+
const quoteString = (value) => `'${value.replaceAll("'", "''")}'`;
|
|
3220
3199
|
|
|
3221
3200
|
const makeMessage = (colors, timeColor, time, sqlColor, sql, valuesColor, values) => {
|
|
3222
3201
|
const elapsed = process.hrtime(time);
|