rado 0.2.30 → 0.2.31

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.
@@ -53,7 +53,7 @@ export declare abstract class Formatter implements Sanitizer {
53
53
  formatSelect({ topLevel, ...ctx }: FormatContext, query: QueryData.Select): Statement;
54
54
  formatUnion(ctx: FormatContext, { a, operator, b }: QueryData.Union): Statement;
55
55
  formatInsert(ctx: FormatContext, query: QueryData.Insert): Statement;
56
- formatUpdate(ctx: FormatContext, query: QueryData.Update): Statement;
56
+ formatUpdate({ topLevel, ...ctx }: FormatContext, query: QueryData.Update): Statement;
57
57
  formatDelete(ctx: FormatContext, query: QueryData.Delete): Statement;
58
58
  formatCreateTable(ctx: FormatContext, query: QueryData.CreateTable): Statement;
59
59
  formatCreateIndex(ctx: FormatContext, query: QueryData.CreateIndex): Statement;
@@ -158,18 +158,22 @@ var Formatter = class {
158
158
  }
159
159
  return stmt;
160
160
  }
161
- formatUpdate(ctx, query) {
161
+ formatUpdate({ topLevel, ...ctx }, query) {
162
162
  const { stmt } = ctx;
163
163
  const data = query.set || {};
164
164
  stmt.add("UPDATE").addIdentifier(query.table.name).add("SET").space();
165
165
  const keys = Object.keys(data).filter((key) => query.table.columns[key]);
166
166
  for (const key of stmt.separate(keys)) {
167
+ const column = query.table.columns[key];
167
168
  stmt.identifier(key).add("=").space();
168
169
  let input = data[key];
169
170
  if (Expr.hasExpr(input))
170
171
  input = input[Expr.ToExpr]();
171
172
  if (Expr.isExpr(input))
172
- this.formatExprJson(ctx, ExprData.create(data[key]));
173
+ this.formatExpr(
174
+ { ...ctx, formatAsJson: column.type === ColumnType.Json },
175
+ ExprData.create(data[key])
176
+ );
173
177
  else
174
178
  this.formatValue({ ...ctx, formatAsInsert: true }, input);
175
179
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rado",
3
- "version": "0.2.30",
3
+ "version": "0.2.31",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",