rado 0.1.51 → 0.1.52

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.
@@ -31,7 +31,7 @@ var Cursor = class {
31
31
  function addWhere(query, where) {
32
32
  const conditions = where.slice();
33
33
  if (query.where)
34
- conditions.push(query.where);
34
+ conditions.push(new Expr(query.where));
35
35
  return {
36
36
  ...query,
37
37
  where: Expr.and(...conditions).expr
@@ -96,8 +96,11 @@ var Formatter = class {
96
96
  for (const column of stmt.call(columns))
97
97
  this.formatString(ctx, column.name);
98
98
  stmt.add("VALUES");
99
- for (const row of stmt.separate(query.data))
100
- this.formatInsertRow(ctx, query.into.columns, row);
99
+ if (query.data.length === 0)
100
+ stmt.add("()");
101
+ else
102
+ for (const row of stmt.separate(query.data))
103
+ this.formatInsertRow(ctx, query.into.columns, row);
101
104
  if (query.selection) {
102
105
  stmt.add("RETURNING").space();
103
106
  this.formatSelection(ctx, query.selection, formatAsResultObject);
@@ -330,9 +333,9 @@ var Formatter = class {
330
333
  case TargetType.Join:
331
334
  const { left, right, joinType } = target;
332
335
  this.formatTarget(ctx, left);
333
- stmt.addLine(joins[joinType]).add("JOIN");
336
+ stmt.addLine(joins[joinType]).add("JOIN").space();
334
337
  this.formatTarget(ctx, right);
335
- stmt.add("ON");
338
+ stmt.add("ON").space();
336
339
  this.formatExprValue(ctx, target.on);
337
340
  return stmt;
338
341
  case TargetType.Query:
@@ -1,4 +1,3 @@
1
1
  export declare class SqlError extends Error {
2
- sql: string;
3
2
  constructor(cause: Error, sql: string);
4
3
  }
@@ -4,7 +4,6 @@ var SqlError = class extends Error {
4
4
  super(`${sql}
5
5
  \u2502
6
6
  \u2514\u2500\u2500\u2500\u2500 ${cause}`, { cause });
7
- this.sql = sql;
8
7
  }
9
8
  };
10
9
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rado",
3
- "version": "0.1.51",
3
+ "version": "0.1.52",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",