rado 0.1.2 → 0.1.4

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/Formatter.js CHANGED
@@ -130,7 +130,7 @@ var Formatter = class {
130
130
  ).add(this.formatWhere(query.where, ctx));
131
131
  }
132
132
  formatDropIndex(query, ctx) {
133
- return raw("drop index").addIf(query.ifExists, "if exists").addIdentifier(query.index.name);
133
+ return raw("drop index").addIf(query.ifExists, "if exists").addIdentifier(query.name);
134
134
  }
135
135
  formatAlterTable(query, ctx) {
136
136
  let stmt = raw("alter table").addIdentifier(query.table.name);
package/dist/Query.d.ts CHANGED
@@ -68,7 +68,7 @@ export declare namespace Query {
68
68
  interface DropIndex extends QueryBase {
69
69
  type: QueryType.DropIndex;
70
70
  table: Schema;
71
- index: Index;
71
+ name: string;
72
72
  ifExists?: boolean;
73
73
  }
74
74
  function DropIndex(drop: Omit<DropIndex, 'type'>): Query.DropIndex;
package/dist/Schema.js CHANGED
@@ -40,13 +40,13 @@ var Schema;
40
40
  if (!localInstruction) {
41
41
  res.push(Query.CreateIndex({ table: schema, index: schemaIndex }));
42
42
  } else if (!schemaIndex) {
43
- res.push(Query.DropIndex({ table: schema, index: schemaIndex }));
43
+ res.push(Query.DropIndex({ table: schema, name: indexName }));
44
44
  } else {
45
45
  const [instruction] = formatter.formatCreateIndex(
46
46
  Query.CreateIndex({ table: schema, index: schemaIndex })
47
47
  ).compile(formatter);
48
48
  if (localInstruction !== instruction) {
49
- res.push(Query.DropIndex({ table: schema, index: schemaIndex }));
49
+ res.push(Query.DropIndex({ table: schema, name: indexName }));
50
50
  res.push(Query.CreateIndex({ table: schema, index: schemaIndex }));
51
51
  }
52
52
  }
@@ -1,5 +1,5 @@
1
1
  // src/sqlite/SqliteSchema.ts
2
- import { Statement, identifier } from "../Statement.js";
2
+ import { Statement, identifier, raw } from "../Statement.js";
3
3
  import { SqliteFormatter } from "./SqliteFormatter.js";
4
4
  var SqliteSchema;
5
5
  ((SqliteSchema2) => {
@@ -16,7 +16,7 @@ var SqliteSchema;
16
16
  if (columnData.length === 0 && indexData2.length === 0)
17
17
  return void 0;
18
18
  const columns = columnData.map(columnInstruction);
19
- const indexes = indexData2.map(indexInstruction);
19
+ const indexes = indexData2.map(indexInstruction).filter((row) => row[1]);
20
20
  return {
21
21
  columns: Object.fromEntries(columns),
22
22
  indexes: Object.fromEntries(indexes)
@@ -26,7 +26,10 @@ var SqliteSchema;
26
26
  function columnInstruction(column) {
27
27
  return [
28
28
  column.name,
29
- identifier(column.name).add(column.type.toLowerCase()).addIf(column.pk === 1, "primary key").addIf(column.notnull === 1, "not null").addIf(column.dflt_value !== null, column.dflt_value).compile(formatter)[0]
29
+ identifier(column.name).add(column.type.toLowerCase()).addIf(column.pk === 1, "primary key").addIf(column.notnull === 1, "not null").addIf(
30
+ column.dflt_value !== null,
31
+ raw("default").add(column.dflt_value)
32
+ ).compile(formatter)[0]
30
33
  ];
31
34
  }
32
35
  SqliteSchema2.columnInstruction = columnInstruction;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rado",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {