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