rado 0.2.36 → 0.2.38

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.
@@ -7,6 +7,6 @@ export interface SchemaInstructions {
7
7
  }
8
8
  export declare namespace Schema {
9
9
  function create(schema: TableData): QueryData.Batch;
10
- function upgrade(formatter: Formatter, local: SchemaInstructions, schema: TableData): Array<QueryData>;
10
+ function upgrade(formatter: Formatter, local: SchemaInstructions, schema: TableData, verbose?: boolean): Array<QueryData>;
11
11
  }
12
12
  export declare function schema(...tables: Array<Table<any>>): void;
@@ -53,7 +53,7 @@ var Schema;
53
53
  queries.push(new QueryData.CreateIndex({ table, index }));
54
54
  return queries;
55
55
  }
56
- function upgrade(formatter, local, schema2) {
56
+ function upgrade(formatter, local, schema2, verbose = true) {
57
57
  const columnNames = /* @__PURE__ */ new Set([
58
58
  ...Object.keys(local.columns),
59
59
  ...Object.keys(schema2.columns)
@@ -67,16 +67,22 @@ var Schema;
67
67
  res.push(
68
68
  new QueryData.AlterTable({ table: schema2, addColumn: schemaCol })
69
69
  );
70
+ if (verbose)
71
+ console.log(`Adding column ${columnName}`);
70
72
  } else if (!schemaCol) {
71
73
  res.push(
72
74
  new QueryData.AlterTable({ table: schema2, dropColumn: columnName })
73
75
  );
76
+ if (verbose)
77
+ console.log(`Removing column ${columnName}`);
74
78
  } else {
75
79
  const { sql: instruction } = formatter.formatColumn(
76
80
  { stmt: new Statement(formatter) },
77
81
  { ...schemaCol, references: void 0 }
78
82
  );
79
83
  if (removeLeadingWhitespace(localInstruction) !== removeLeadingWhitespace(instruction)) {
84
+ if (verbose)
85
+ console.log(`Recreating because ${columnName} differs`);
80
86
  recreate = true;
81
87
  }
82
88
  }
@@ -97,13 +103,19 @@ var Schema;
97
103
  const schemaIndex = meta.indexes[indexName];
98
104
  if (!localInstruction) {
99
105
  res.push(new QueryData.CreateIndex({ table: schema2, index: schemaIndex }));
106
+ if (verbose)
107
+ console.log(`Adding index ${indexName}`);
100
108
  } else if (!schemaIndex) {
101
109
  res.unshift(new QueryData.DropIndex({ table: schema2, name: indexName }));
110
+ if (verbose)
111
+ console.log(`Removing index ${indexName}`);
102
112
  } else {
103
113
  const { sql: instruction } = formatter.compile(
104
114
  new QueryData.CreateIndex({ table: schema2, index: schemaIndex })
105
115
  );
106
116
  if (removeLeadingWhitespace(localInstruction) !== removeLeadingWhitespace(instruction)) {
117
+ if (verbose)
118
+ console.log(`Recreating index ${indexName}`);
107
119
  res.unshift(new QueryData.DropIndex({ table: schema2, name: indexName }));
108
120
  res.push(
109
121
  new QueryData.CreateIndex({ table: schema2, index: schemaIndex })
@@ -678,7 +678,7 @@ class Formatter {
678
678
  const { stmt } = ctx;
679
679
  if (!ctx.formatAsJson) {
680
680
  stmt.openParenthesis();
681
- this.format(ctx, expr.query);
681
+ this.format({ ...ctx, formatAsIn: false }, expr.query);
682
682
  return stmt.closeParenthesis();
683
683
  }
684
684
  if (expr.query.singleResult) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rado",
3
- "version": "0.2.36",
3
+ "version": "0.2.38",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",