rado 0.1.57 → 0.1.59
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/lib/Formatter.js +8 -4
- package/package.json +1 -1
package/dist/lib/Formatter.js
CHANGED
|
@@ -116,7 +116,8 @@ var Formatter = class {
|
|
|
116
116
|
const { stmt } = ctx;
|
|
117
117
|
const data = query.set || {};
|
|
118
118
|
stmt.add("UPDATE").addIdentifier(query.table.name).add("SET").space();
|
|
119
|
-
|
|
119
|
+
const keys = Object.keys(data).filter((key) => query.table.columns[key]);
|
|
120
|
+
for (const key of stmt.separate(keys)) {
|
|
120
121
|
stmt.identifier(key).add("=").space();
|
|
121
122
|
const value = data[key];
|
|
122
123
|
if (value instanceof Expr)
|
|
@@ -495,13 +496,13 @@ var Formatter = class {
|
|
|
495
496
|
}
|
|
496
497
|
formatValue(ctx, rawValue) {
|
|
497
498
|
const { stmt, formatAsJson, formatAsInsert, forceInline } = ctx;
|
|
499
|
+
const asJson = formatAsJson || formatAsInsert;
|
|
498
500
|
switch (true) {
|
|
499
501
|
case (rawValue === null || rawValue === void 0):
|
|
500
502
|
return stmt.raw("NULL");
|
|
501
503
|
case ((formatAsInsert || !formatAsJson) && typeof rawValue === "boolean"):
|
|
502
504
|
return rawValue ? stmt.raw("1") : stmt.raw("0");
|
|
503
|
-
case Array.isArray(rawValue):
|
|
504
|
-
const asJson = formatAsJson || formatAsInsert;
|
|
505
|
+
case (!formatAsInsert && Array.isArray(rawValue)):
|
|
505
506
|
if (asJson)
|
|
506
507
|
stmt.raw("json_array");
|
|
507
508
|
stmt.openParenthesis();
|
|
@@ -518,7 +519,10 @@ var Formatter = class {
|
|
|
518
519
|
stmt.raw("json");
|
|
519
520
|
stmt.openParenthesis();
|
|
520
521
|
}
|
|
521
|
-
|
|
522
|
+
if (forceInline)
|
|
523
|
+
this.formatString(ctx, JSON.stringify(rawValue));
|
|
524
|
+
else
|
|
525
|
+
stmt.value(JSON.stringify(rawValue));
|
|
522
526
|
if (formatAsJson)
|
|
523
527
|
stmt.closeParenthesis();
|
|
524
528
|
return stmt;
|