rado 0.0.0 → 0.1.1

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/Column.d.ts CHANGED
@@ -1,28 +1,33 @@
1
+ import { Expr, ExprData } from './Expr';
1
2
  export declare const enum ColumnType {
2
3
  String = "String",
3
4
  Integer = "Integer",
4
5
  Number = "Number",
5
6
  Boolean = "Boolean",
6
- Object = "Object",
7
- Array = "Array"
7
+ Json = "Json"
8
8
  }
9
- export interface ColumnData {
9
+ interface PartialColumnData {
10
10
  type: ColumnType;
11
11
  name?: string;
12
12
  nullable?: boolean;
13
+ defaultValue?: any;
13
14
  autoIncrement?: boolean;
14
15
  primaryKey?: boolean;
15
16
  unique?: boolean;
16
- defaultValue?: any;
17
- generated?: boolean;
17
+ references?: ExprData;
18
+ }
19
+ export interface ColumnData extends PartialColumnData {
20
+ type: ColumnType;
21
+ name: string;
18
22
  }
19
23
  export declare class Column<T = any> {
20
- data: ColumnData;
21
- constructor(data: ColumnData);
24
+ data: PartialColumnData;
25
+ constructor(data: PartialColumnData);
22
26
  name(name: string): Column<T>;
23
27
  nullable(): Column<T | null>;
24
28
  autoIncrement(): Column<T & Column.Optional>;
25
29
  primaryKey(): Column<T & Column.Optional>;
30
+ references(column: Expr<T>): Column<any>;
26
31
  unique(): Column<T>;
27
32
  defaultValue(value: T): Column<T & Column.Optional>;
28
33
  }
@@ -41,3 +46,4 @@ export declare const column: {
41
46
  object<T_4 extends object = object>(): Column<T_4>;
42
47
  array<T_5 = any>(): Column<T_5[]>;
43
48
  };
49
+ export {};
package/dist/Column.js CHANGED
@@ -1,11 +1,11 @@
1
1
  // src/Column.ts
2
+ import { ExprData } from "./Expr.js";
2
3
  var ColumnType = /* @__PURE__ */ ((ColumnType2) => {
3
4
  ColumnType2["String"] = "String";
4
5
  ColumnType2["Integer"] = "Integer";
5
6
  ColumnType2["Number"] = "Number";
6
7
  ColumnType2["Boolean"] = "Boolean";
7
- ColumnType2["Object"] = "Object";
8
- ColumnType2["Array"] = "Array";
8
+ ColumnType2["Json"] = "Json";
9
9
  return ColumnType2;
10
10
  })(ColumnType || {});
11
11
  var Column = class {
@@ -24,6 +24,9 @@ var Column = class {
24
24
  primaryKey() {
25
25
  return new Column({ ...this.data, primaryKey: true });
26
26
  }
27
+ references(column2) {
28
+ return new Column({ ...this.data, references: ExprData.create(column2) });
29
+ }
27
30
  unique() {
28
31
  return new Column({ ...this.data, unique: true });
29
32
  }
@@ -45,10 +48,10 @@ var column = {
45
48
  return new Column({ type: "Boolean" /* Boolean */ });
46
49
  },
47
50
  object() {
48
- return new Column({ type: "Object" /* Object */ });
51
+ return new Column({ type: "Json" /* Json */ });
49
52
  },
50
53
  array() {
51
- return new Column({ type: "Array" /* Array */ });
54
+ return new Column({ type: "Json" /* Json */ });
52
55
  }
53
56
  };
54
57
  export {
package/dist/Cursor.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import { EV, Expr } from './Expr';
2
2
  import { OrderBy } from './OrderBy';
3
3
  import { Query } from './Query';
4
+ import { Schema } from './Schema';
4
5
  import { Selection } from './Selection';
5
- import { Table, TableData } from './Table';
6
+ import { Table } from './Table';
6
7
  import { Update as UpdateSet } from './Update';
7
8
  export declare class Cursor<T> {
8
9
  /** @internal */
@@ -39,13 +40,13 @@ export declare namespace Cursor {
39
40
  returning<X extends Selection>(selection: X): InsertValuesReturning<Selection.Infer<X>>;
40
41
  }
41
42
  class Insert<T> {
42
- protected into: TableData;
43
- constructor(into: TableData);
43
+ protected into: Schema;
44
+ constructor(into: Schema);
44
45
  values(...data: Array<Table.Insert<T>>): InsertValues;
45
46
  }
46
47
  class Create extends Cursor<void> {
47
- protected table: TableData;
48
- constructor(table: TableData);
48
+ protected table: Schema;
49
+ constructor(table: Schema);
49
50
  }
50
51
  class Batch<T = void> extends Cursor<T> {
51
52
  protected queries: Array<Query>;
package/dist/Cursor.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { Expr, ExprData } from "./Expr.js";
3
3
  import { Functions } from "./Functions.js";
4
4
  import { Query } from "./Query.js";
5
+ import { Schema } from "./Schema.js";
5
6
  import { Target } from "./Target.js";
6
7
  var Cursor = class {
7
8
  constructor(query) {
@@ -75,7 +76,7 @@ var Cursor = class {
75
76
  Cursor2.Insert = Insert;
76
77
  class Create extends Cursor2 {
77
78
  constructor(table) {
78
- super(Query.CreateTable({ table, ifNotExists: true }));
79
+ super(Schema.create(table));
79
80
  this.table = table;
80
81
  }
81
82
  }
@@ -97,7 +98,7 @@ var Cursor = class {
97
98
  ...query,
98
99
  from: Target.Join(
99
100
  query.from,
100
- Target.Table(that.data()),
101
+ Target.Table(that.schema()),
101
102
  "left",
102
103
  Expr.and(...on).expr
103
104
  )
@@ -109,7 +110,7 @@ var Cursor = class {
109
110
  ...query,
110
111
  from: Target.Join(
111
112
  query.from,
112
- Target.Table(that.data()),
113
+ Target.Table(that.schema()),
113
114
  "inner",
114
115
  Expr.and(...on).expr
115
116
  )
@@ -161,7 +162,7 @@ var Cursor = class {
161
162
  ...query,
162
163
  from: Target.Join(
163
164
  query.from,
164
- Target.Table(that.data()),
165
+ Target.Table(that.schema()),
165
166
  "left",
166
167
  Expr.and(...on).expr
167
168
  )
@@ -173,7 +174,7 @@ var Cursor = class {
173
174
  ...query,
174
175
  from: Target.Join(
175
176
  query.from,
176
- Target.Table(that.data()),
177
+ Target.Table(that.schema()),
177
178
  "inner",
178
179
  Expr.and(...on).expr
179
180
  )
package/dist/Driver.d.ts CHANGED
@@ -1,49 +1,78 @@
1
1
  import { Cursor } from './Cursor';
2
+ import { Formatter } from './Formatter';
2
3
  import { Query } from './Query';
4
+ import { SchemaInstructions } from './Schema';
5
+ import { Statement } from './Statement';
6
+ import { Table } from './Table';
3
7
  declare class Callable extends Function {
4
8
  constructor(fn: Function);
5
9
  }
6
10
  declare abstract class DriverBase extends Callable {
7
- constructor();
11
+ formatter: Formatter;
12
+ constructor(formatter: Formatter);
8
13
  all(strings: TemplateStringsArray, ...params: Array<any>): any;
9
14
  get(strings: TemplateStringsArray, ...params: Array<any>): any;
10
15
  executeTemplate(expectedReturn: Query.RawReturn, strings: TemplateStringsArray, ...params: Array<any>): any;
11
16
  abstract executeQuery(query: Query<any>): any;
12
17
  }
18
+ interface SyncDriver {
19
+ <T>(query: Cursor<T>): T;
20
+ (strings: TemplateStringsArray, ...values: any[]): any;
21
+ }
22
+ declare abstract class SyncDriver extends DriverBase {
23
+ transactionId: number;
24
+ abstract rows(stmt: Statement.Compiled): Array<object>;
25
+ abstract values(stmt: Statement.Compiled): Array<Array<any>>;
26
+ abstract execute(stmt: Statement.Compiled): void;
27
+ abstract mutate(stmt: Statement.Compiled): {
28
+ rowsAffected: number;
29
+ };
30
+ abstract schemaInstructions(tableName: string): SchemaInstructions | undefined;
31
+ migrateSchema(...tables: Array<Table<any>>): unknown;
32
+ executeQuery<T>(query: Query<T>): T;
33
+ all<T>(strings: TemplateStringsArray, ...params: Array<any>): Array<T>;
34
+ get<T>(strings: TemplateStringsArray, ...params: Array<any>): T;
35
+ transaction<T>(run: (query: SyncDriver) => T): T;
36
+ toAsync(): SyncWrapper;
37
+ }
38
+ interface AsyncDriver {
39
+ <T>(query: Cursor<T>): Promise<T>;
40
+ (strings: TemplateStringsArray, ...values: any[]): Promise<any>;
41
+ }
42
+ declare abstract class AsyncDriver extends DriverBase {
43
+ transactionId: number;
44
+ abstract isolate(): [connection: AsyncDriver, release: () => Promise<void>];
45
+ abstract rows(stmt: Statement.Compiled): Promise<Array<object>>;
46
+ abstract values(stmt: Statement.Compiled): Promise<Array<Array<any>>>;
47
+ abstract execute(stmt: Statement.Compiled): Promise<void>;
48
+ abstract mutate(stmt: Statement.Compiled): Promise<{
49
+ rowsAffected: number;
50
+ }>;
51
+ abstract schemaInstructions(tableName: string): Promise<SchemaInstructions | undefined>;
52
+ migrateSchema(...tables: Array<Table<any>>): Promise<unknown>;
53
+ executeQuery<T>(query: Query<T>): Promise<T>;
54
+ all<T>(strings: TemplateStringsArray, ...params: Array<any>): Promise<Array<T>>;
55
+ get<T>(strings: TemplateStringsArray, ...params: Array<any>): Promise<T>;
56
+ transaction<T>(run: (query: AsyncDriver) => T): Promise<T>;
57
+ }
58
+ declare class SyncWrapper extends AsyncDriver {
59
+ private sync;
60
+ lock: Promise<void> | undefined;
61
+ constructor(sync: SyncDriver);
62
+ executeQuery<T>(query: Query<T>): Promise<T>;
63
+ rows(stmt: Statement.Compiled): Promise<Array<object>>;
64
+ values(stmt: Statement.Compiled): Promise<Array<Array<any>>>;
65
+ execute(stmt: Statement.Compiled): Promise<void>;
66
+ mutate(stmt: Statement.Compiled): Promise<{
67
+ rowsAffected: number;
68
+ }>;
69
+ schemaInstructions(tableName: string): Promise<SchemaInstructions | undefined>;
70
+ isolate(): [connection: AsyncDriver, release: () => Promise<void>];
71
+ }
13
72
  export declare namespace Driver {
14
- export interface Sync {
15
- <T>(query: Cursor<T>): T;
16
- (strings: TemplateStringsArray, ...values: any[]): any;
17
- }
18
- export abstract class Sync extends DriverBase {
19
- transactionId: number;
20
- abstract execute(query: Query): any;
21
- executeQuery<T>(query: Query<T>): T;
22
- all<T>(strings: TemplateStringsArray, ...params: Array<any>): Array<T>;
23
- get<T>(strings: TemplateStringsArray, ...params: Array<any>): T;
24
- transaction<T>(run: (query: Sync) => T): T;
25
- toAsync(): SyncWrapper;
26
- }
27
- export interface Async {
28
- <T>(query: Cursor<T>): Promise<T>;
29
- (strings: TemplateStringsArray, ...values: any[]): Promise<any>;
30
- }
31
- export abstract class Async extends DriverBase {
32
- transactionId: number;
33
- abstract execute(query: Query): Promise<any>;
34
- abstract isolate(): [connection: Async, release: () => Promise<void>];
35
- executeQuery<T>(query: Query<T>): Promise<T>;
36
- all<T>(strings: TemplateStringsArray, ...params: Array<any>): Promise<Array<T>>;
37
- get<T>(strings: TemplateStringsArray, ...params: Array<any>): Promise<T>;
38
- transaction<T>(run: (query: Async) => T): Promise<T>;
39
- }
40
- class SyncWrapper extends Async {
41
- private sync;
42
- lock: Promise<void> | undefined;
43
- constructor(sync: Sync);
44
- execute<T>(query: Query<T>): Promise<T>;
45
- isolate(): [connection: Async, release: () => Promise<void>];
46
- }
47
- export {};
73
+ type Sync = SyncDriver;
74
+ const Sync: typeof SyncDriver;
75
+ type Async = AsyncDriver;
76
+ const Async: typeof AsyncDriver;
48
77
  }
49
78
  export {};
package/dist/Driver.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // src/Driver.ts
2
2
  import { Cursor } from "./Cursor.js";
3
3
  import { Query, QueryType } from "./Query.js";
4
+ import { Schema } from "./Schema.js";
4
5
  var Callable = class extends Function {
5
6
  constructor(fn) {
6
7
  super();
@@ -12,13 +13,14 @@ var Callable = class extends Function {
12
13
  }
13
14
  };
14
15
  var DriverBase = class extends Callable {
15
- constructor() {
16
+ constructor(formatter) {
16
17
  super((...args) => {
17
18
  const [input, ...rest] = args;
18
19
  if (input instanceof Cursor)
19
20
  return this.executeQuery(input.query());
20
21
  return this.executeTemplate(void 0, input, ...rest);
21
22
  });
23
+ this.formatter = formatter;
22
24
  }
23
25
  all(strings, ...params) {
24
26
  return this.executeTemplate("rows", strings, ...params);
@@ -32,113 +34,208 @@ var DriverBase = class extends Callable {
32
34
  return this.executeQuery(Query.Raw({ strings, params, expectedReturn }));
33
35
  }
34
36
  };
35
- var Driver;
36
- ((Driver2) => {
37
- class Sync extends DriverBase {
38
- transactionId = 0;
39
- executeQuery(query) {
40
- switch (query.type) {
41
- case QueryType.Batch:
42
- let result;
43
- const stmts = query.queries;
44
- for (const query2 of stmts)
45
- result = this.execute(query2);
46
- return result;
47
- default:
48
- return this.execute(query);
37
+ var SyncDriver = class extends DriverBase {
38
+ transactionId = 0;
39
+ migrateSchema(...tables) {
40
+ const queries = [];
41
+ for (const table of Object.values(tables)) {
42
+ const schema = table.schema();
43
+ const localSchema = this.schemaInstructions(schema.name);
44
+ if (!localSchema) {
45
+ queries.push(...Schema.create(schema).queries);
46
+ } else {
47
+ const changes = Schema.upgrade(this.formatter, localSchema, schema);
48
+ if (changes.length)
49
+ queries.push(...changes);
49
50
  }
50
51
  }
51
- all(strings, ...params) {
52
- return super.all(strings, ...params);
53
- }
54
- get(strings, ...params) {
55
- return super.get(strings, ...params);
52
+ return this.executeQuery(Query.Batch({ queries }));
53
+ }
54
+ executeQuery(query) {
55
+ switch (query.type) {
56
+ case QueryType.Batch:
57
+ let result;
58
+ const stmts = query.queries;
59
+ if (stmts.length === 0)
60
+ return void 0;
61
+ if (stmts.length === 1)
62
+ return this.executeQuery(stmts[0]);
63
+ return this.transaction((cnx) => {
64
+ for (const query2 of stmts)
65
+ result = cnx.executeQuery(query2);
66
+ return result;
67
+ });
68
+ default:
69
+ const stmt = this.formatter.compile(query);
70
+ if ("selection" in query) {
71
+ const res = this.values(stmt).map(([item]) => JSON.parse(item).result);
72
+ if (query.singleResult)
73
+ return res[0];
74
+ return res;
75
+ } else if (query.type === QueryType.Raw) {
76
+ switch (query.expectedReturn) {
77
+ case "row":
78
+ return this.rows(stmt)[0];
79
+ case "rows":
80
+ return this.rows(stmt);
81
+ default:
82
+ this.execute(stmt);
83
+ return void 0;
84
+ }
85
+ } else {
86
+ return this.mutate(stmt);
87
+ }
56
88
  }
57
- transaction(run) {
58
- const id = `t${this.transactionId++}`;
59
- this.execute(
60
- Query.Transaction({ op: Query.TransactionOperation.Begin, id })
89
+ }
90
+ all(strings, ...params) {
91
+ return super.all(strings, ...params);
92
+ }
93
+ get(strings, ...params) {
94
+ return super.get(strings, ...params);
95
+ }
96
+ transaction(run) {
97
+ const id = `t${this.transactionId++}`;
98
+ this.executeQuery(
99
+ Query.Transaction({ op: Query.TransactionOperation.Begin, id })
100
+ );
101
+ try {
102
+ const res = run(this);
103
+ this.executeQuery(
104
+ Query.Transaction({ op: Query.TransactionOperation.Commit, id })
61
105
  );
62
- try {
63
- const res = run(this);
64
- this.execute(
65
- Query.Transaction({ op: Query.TransactionOperation.Commit, id })
66
- );
67
- return res;
68
- } catch (e) {
69
- this.execute(
70
- Query.Transaction({ op: Query.TransactionOperation.Rollback, id })
71
- );
72
- throw e;
73
- }
106
+ return res;
107
+ } catch (e) {
108
+ this.executeQuery(
109
+ Query.Transaction({ op: Query.TransactionOperation.Rollback, id })
110
+ );
111
+ throw e;
74
112
  }
75
- toAsync() {
76
- return new SyncWrapper(this);
113
+ }
114
+ toAsync() {
115
+ return new SyncWrapper(this);
116
+ }
117
+ };
118
+ var AsyncDriver = class extends DriverBase {
119
+ transactionId = 0;
120
+ async migrateSchema(...tables) {
121
+ const queries = [];
122
+ for (const table of Object.values(tables)) {
123
+ const schema = table.schema();
124
+ const localSchema = await this.schemaInstructions(schema.name);
125
+ if (!localSchema) {
126
+ queries.push(...Schema.create(schema).queries);
127
+ } else {
128
+ const changes = Schema.upgrade(this.formatter, localSchema, schema);
129
+ if (changes.length)
130
+ queries.push(...changes);
131
+ }
77
132
  }
133
+ return this.executeQuery(Query.Batch({ queries }));
78
134
  }
79
- Driver2.Sync = Sync;
80
- class Async extends DriverBase {
81
- transactionId = 0;
82
- async executeQuery(query) {
83
- switch (query.type) {
84
- case QueryType.Batch:
85
- let result;
86
- const stmts = query.queries;
135
+ async executeQuery(query) {
136
+ switch (query.type) {
137
+ case QueryType.Batch:
138
+ let result;
139
+ const stmts = query.queries;
140
+ if (stmts.length === 0)
141
+ return void 0;
142
+ if (stmts.length === 1)
143
+ return this.executeQuery(stmts[0]);
144
+ return this.transaction(async (cnx) => {
87
145
  for (const query2 of stmts)
88
- result = await this.execute(query2);
146
+ result = await cnx.executeQuery(query2);
89
147
  return result;
90
- default:
91
- return this.execute(query);
92
- }
93
- }
94
- all(strings, ...params) {
95
- return super.all(strings, ...params);
96
- }
97
- get(strings, ...params) {
98
- return super.get(strings, ...params);
148
+ });
149
+ default:
150
+ const stmt = this.formatter.compile(query);
151
+ if ("selection" in query) {
152
+ const res = (await this.values(stmt)).map(
153
+ ([item]) => JSON.parse(item).result
154
+ );
155
+ if (query.singleResult)
156
+ return res[0];
157
+ return res;
158
+ } else if (query.type === QueryType.Raw) {
159
+ switch (query.expectedReturn) {
160
+ case "row":
161
+ return (await this.rows(stmt))[0];
162
+ case "rows":
163
+ return await this.rows(stmt);
164
+ default:
165
+ await this.execute(stmt);
166
+ return void 0;
167
+ }
168
+ } else {
169
+ return await this.mutate(stmt);
170
+ }
99
171
  }
100
- async transaction(run) {
101
- const id = `t${this.transactionId++}`;
102
- const [connection, release] = this.isolate();
103
- await connection.execute(
104
- Query.Transaction({ op: Query.TransactionOperation.Begin, id })
172
+ }
173
+ all(strings, ...params) {
174
+ return super.all(strings, ...params);
175
+ }
176
+ get(strings, ...params) {
177
+ return super.get(strings, ...params);
178
+ }
179
+ async transaction(run) {
180
+ const id = `t${this.transactionId++}`;
181
+ const [connection, release] = this.isolate();
182
+ await connection.executeQuery(
183
+ Query.Transaction({ op: Query.TransactionOperation.Begin, id })
184
+ );
185
+ try {
186
+ const res = await run(connection);
187
+ await connection.executeQuery(
188
+ Query.Transaction({ op: Query.TransactionOperation.Commit, id })
105
189
  );
106
- try {
107
- const res = await run(connection);
108
- await connection.execute(
109
- Query.Transaction({ op: Query.TransactionOperation.Commit, id })
110
- );
111
- return res;
112
- } catch (e) {
113
- await connection.execute(
114
- Query.Transaction({ op: Query.TransactionOperation.Rollback, id })
115
- );
116
- throw e;
117
- } finally {
118
- await release();
119
- }
190
+ return res;
191
+ } catch (e) {
192
+ await connection.executeQuery(
193
+ Query.Transaction({ op: Query.TransactionOperation.Rollback, id })
194
+ );
195
+ throw e;
196
+ } finally {
197
+ await release();
120
198
  }
121
199
  }
122
- Driver2.Async = Async;
123
- class SyncWrapper extends Async {
124
- constructor(sync) {
125
- super();
126
- this.sync = sync;
127
- }
128
- lock;
129
- async execute(query) {
130
- await this.lock;
131
- return this.sync.execute(query);
132
- }
133
- isolate() {
134
- const connection = new SyncWrapper(this.sync);
135
- let release, trigger = new Promise((resolve) => {
136
- release = async () => resolve();
137
- });
138
- this.lock = Promise.resolve(this.lock).then(() => trigger);
139
- return [connection, release];
140
- }
200
+ };
201
+ var SyncWrapper = class extends AsyncDriver {
202
+ constructor(sync) {
203
+ super(sync.formatter);
204
+ this.sync = sync;
141
205
  }
206
+ lock;
207
+ async executeQuery(query) {
208
+ await this.lock;
209
+ return super.executeQuery(query);
210
+ }
211
+ async rows(stmt) {
212
+ return this.sync.rows(stmt);
213
+ }
214
+ async values(stmt) {
215
+ return this.sync.values(stmt);
216
+ }
217
+ async execute(stmt) {
218
+ return this.sync.execute(stmt);
219
+ }
220
+ async mutate(stmt) {
221
+ return this.sync.mutate(stmt);
222
+ }
223
+ async schemaInstructions(tableName) {
224
+ return this.sync.schemaInstructions(tableName);
225
+ }
226
+ isolate() {
227
+ const connection = new SyncWrapper(this.sync);
228
+ let release, trigger = new Promise((resolve) => {
229
+ release = async () => resolve();
230
+ });
231
+ this.lock = Promise.resolve(this.lock).then(() => trigger);
232
+ return [connection, release];
233
+ }
234
+ };
235
+ var Driver;
236
+ ((Driver2) => {
237
+ Driver2.Sync = SyncDriver;
238
+ Driver2.Async = AsyncDriver;
142
239
  })(Driver || (Driver = {}));
143
240
  export {
144
241
  Driver
@@ -7,27 +7,32 @@ import { Statement } from './Statement';
7
7
  import { Target } from './Target';
8
8
  export interface FormatContext {
9
9
  nameResult?: string;
10
+ skipTableName?: boolean;
10
11
  formatAsJson?: boolean;
11
12
  formatSubject?: (subject: Statement) => Statement;
12
13
  }
13
14
  export declare abstract class Formatter implements Sanitizer {
14
15
  constructor();
15
16
  abstract escapeValue(value: any): string;
16
- abstract escapeIdent(ident: string): string;
17
+ abstract escapeIdentifier(ident: string): string;
17
18
  abstract formatSqlAccess(on: Statement, field: string): Statement;
18
19
  abstract formatJsonAccess(on: Statement, field: string): Statement;
19
20
  formatAccess(on: Statement, field: string, formatAsJson?: boolean): Statement;
20
- compile<T>(query: Query<T>, formatInline?: boolean): [string, any[]];
21
+ compile<T>(query: Query<T>, formatInline?: boolean): Statement.Compiled;
21
22
  format<T>(query: Query<T>, ctx?: FormatContext): Statement;
22
23
  formatSelect(query: Query.Select, ctx: FormatContext): Statement;
23
24
  formatInsert(query: Query.Insert, ctx: FormatContext): Statement;
24
25
  formatUpdate(query: Query.Update, ctx: FormatContext): Statement;
25
26
  formatDelete(query: Query.Delete, ctx: FormatContext): Statement;
26
27
  formatCreateTable(query: Query.CreateTable, ctx: FormatContext): Statement;
28
+ formatCreateIndex(query: Query.CreateIndex, ctx?: FormatContext): Statement;
29
+ formatDropIndex(query: Query.DropIndex, ctx: FormatContext): Statement;
30
+ formatAlterTable(query: Query.AlterTable, ctx: FormatContext): Statement;
27
31
  formatTransaction({ op, id }: Query.Transaction, ctx: FormatContext): Statement;
28
32
  formatBatch(queries: Query[], ctx: FormatContext): Statement;
29
33
  formatRaw({ strings, params }: Query.Raw, ctx: FormatContext): Statement;
30
34
  formatColumn(column: ColumnData): Statement;
35
+ formatContraintReference(reference: ExprData): Statement;
31
36
  formatType(type: ColumnType): Statement;
32
37
  formatInsertRow(columns: Record<string, ColumnData>, row: Record<string, any>): Statement;
33
38
  formatColumnValue(column: ColumnData, columnValue: any): Statement;
@@ -44,6 +49,7 @@ export declare abstract class Formatter implements Sanitizer {
44
49
  retrieveField(expr: ExprData, field: string): ExprData | undefined;
45
50
  formatField(expr: ExprData, field: string, ctx: FormatContext): Statement;
46
51
  formatString(input: string): Statement;
52
+ formatInlineValue(rawValue: any): Statement;
47
53
  formatValue(rawValue: any, formatAsJson?: boolean): Statement;
48
54
  formatExpr(expr: ExprData, ctx: FormatContext): Statement;
49
55
  }