kysely 0.7.8 → 0.9.0
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/README.md +47 -8
- package/dist/cjs/dialect/mysql/mysql-adapter.js +6 -0
- package/dist/cjs/dialect/mysql/mysql-driver.js +5 -5
- package/dist/cjs/dialect/mysql/mysql-query-compiler.d.ts +0 -2
- package/dist/cjs/dialect/mysql/mysql-query-compiler.js +0 -29
- package/dist/cjs/dialect/postgres/postgres-driver.js +5 -5
- package/dist/cjs/operation-node/primitive-value-list-node.js +1 -1
- package/dist/cjs/parser/insert-values-parser.d.ts +1 -1
- package/dist/cjs/parser/join-parser.d.ts +6 -3
- package/dist/cjs/parser/table-parser.d.ts +18 -7
- package/dist/cjs/parser/update-set-parser.d.ts +1 -1
- package/dist/cjs/query-builder/function-builder.d.ts +6 -6
- package/dist/cjs/query-builder/function-builder.js +7 -7
- package/dist/cjs/query-builder/query-builder.d.ts +7 -7
- package/dist/cjs/query-compiler/compiled-query.d.ts +1 -1
- package/dist/cjs/query-compiler/default-query-compiler.d.ts +3 -2
- package/dist/cjs/query-compiler/default-query-compiler.js +21 -27
- package/dist/cjs/query-creator.d.ts +14 -11
- package/dist/cjs/query-creator.js +14 -11
- package/dist/cjs/raw-builder/raw-builder.d.ts +1 -1
- package/dist/cjs/raw-builder/raw-builder.js +6 -6
- package/dist/cjs/schema/alter-table-builder.d.ts +3 -0
- package/dist/cjs/schema/alter-table-builder.js +3 -0
- package/dist/cjs/schema/column-definition-builder.d.ts +14 -5
- package/dist/cjs/schema/create-table-builder.d.ts +55 -10
- package/dist/cjs/schema/create-table-builder.js +52 -13
- package/dist/cjs/schema/schema.d.ts +37 -2
- package/dist/cjs/schema/schema.js +36 -1
- package/dist/cjs/util/object-utils.d.ts +1 -0
- package/dist/cjs/util/object-utils.js +5 -1
- package/dist/cjs/util/type-utils.d.ts +3 -0
- package/dist/esm/dialect/mysql/mysql-adapter.js +6 -0
- package/dist/esm/dialect/mysql/mysql-driver.js +5 -5
- package/dist/esm/dialect/mysql/mysql-query-compiler.d.ts +0 -2
- package/dist/esm/dialect/mysql/mysql-query-compiler.js +0 -29
- package/dist/esm/dialect/postgres/postgres-driver.js +5 -5
- package/dist/esm/operation-node/primitive-value-list-node.js +1 -1
- package/dist/esm/parser/insert-values-parser.d.ts +1 -1
- package/dist/esm/parser/join-parser.d.ts +6 -3
- package/dist/esm/parser/table-parser.d.ts +18 -7
- package/dist/esm/parser/update-set-parser.d.ts +1 -1
- package/dist/esm/query-builder/function-builder.d.ts +6 -6
- package/dist/esm/query-builder/function-builder.js +7 -7
- package/dist/esm/query-builder/query-builder.d.ts +7 -7
- package/dist/esm/query-compiler/compiled-query.d.ts +1 -1
- package/dist/esm/query-compiler/default-query-compiler.d.ts +3 -2
- package/dist/esm/query-compiler/default-query-compiler.js +21 -27
- package/dist/esm/query-creator.d.ts +14 -11
- package/dist/esm/query-creator.js +14 -11
- package/dist/esm/raw-builder/raw-builder.d.ts +1 -1
- package/dist/esm/raw-builder/raw-builder.js +6 -6
- package/dist/esm/schema/alter-table-builder.d.ts +3 -0
- package/dist/esm/schema/alter-table-builder.js +3 -0
- package/dist/esm/schema/column-definition-builder.d.ts +14 -5
- package/dist/esm/schema/create-table-builder.d.ts +55 -10
- package/dist/esm/schema/create-table-builder.js +53 -14
- package/dist/esm/schema/schema.d.ts +37 -2
- package/dist/esm/schema/schema.js +36 -1
- package/dist/esm/util/object-utils.d.ts +1 -0
- package/dist/esm/util/object-utils.js +3 -0
- package/dist/esm/util/type-utils.d.ts +3 -0
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
# [Kysely](https://koskimas.github.io/kysely/index.html)
|
|
5
5
|
|
|
6
6
|
A type-safe and autocompletion-friendly typescript SQL query builder for node.js. Inspired by
|
|
7
|
-
[knex](http://knexjs.org/).
|
|
7
|
+
[knex](http://knexjs.org/). [Here's](https://www.jakso.me/blog/kysely-a-type-safe-sql-query-builder-for-typescript)
|
|
8
|
+
an introductory blog post for you.
|
|
8
9
|
|
|
9
10
|

|
|
10
11
|
|
|
@@ -25,9 +26,8 @@ type-safety! See the [DynamicModule](https://koskimas.github.io/kysely/classes/D
|
|
|
25
26
|
for more info.
|
|
26
27
|
|
|
27
28
|
Kysely is still young and some useful features are propably not yet implemented. If you start
|
|
28
|
-
using Kysely and can't find something you'd want to use, please open an issue
|
|
29
|
-
|
|
30
|
-
[Here](https://www.jakso.me/blog/kysely-a-type-safe-sql-query-builder-for-typescript)'s an introductory blog post about Kysely.
|
|
29
|
+
using Kysely and can't find something you'd want to use, please open an issue or join our
|
|
30
|
+
[discord server](https://discord.gg/C9aJ49mCra).
|
|
31
31
|
|
|
32
32
|
# Table of contents
|
|
33
33
|
|
|
@@ -114,8 +114,6 @@ async function demo() {
|
|
|
114
114
|
|
|
115
115
|
# Query examples
|
|
116
116
|
|
|
117
|
-
The [API documentation](https://koskimas.github.io/kysely/index.html) is full of examples.
|
|
118
|
-
|
|
119
117
|
## Select queries
|
|
120
118
|
|
|
121
119
|
You can find examples of select queries in the documentation of the
|
|
@@ -165,13 +163,15 @@ changes completely. Migrations need to be "frozen in time".
|
|
|
165
163
|
The migrations can use the [Kysely.schema](https://koskimas.github.io/kysely/classes/SchemaModule.html)
|
|
166
164
|
module to modify the schema. Migrations can also run normal queries to modify the data.
|
|
167
165
|
|
|
166
|
+
### PostgreSQL migration example
|
|
167
|
+
|
|
168
168
|
```ts
|
|
169
169
|
import { Kysely } from 'kysely'
|
|
170
170
|
|
|
171
171
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
172
172
|
await db.schema
|
|
173
173
|
.createTable('person')
|
|
174
|
-
.addColumn('id', '
|
|
174
|
+
.addColumn('id', 'serial', (col) => col.primaryKey())
|
|
175
175
|
.addColumn('first_name', 'varchar')
|
|
176
176
|
.addColumn('last_name', 'varchar')
|
|
177
177
|
.addColumn('gender', 'varchar(50)')
|
|
@@ -179,7 +179,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
179
179
|
|
|
180
180
|
await db.schema
|
|
181
181
|
.createTable('pet')
|
|
182
|
-
.addColumn('id', '
|
|
182
|
+
.addColumn('id', 'serial', (col) => col.primaryKey())
|
|
183
183
|
.addColumn('name', 'varchar', (col) => col.notNull().unique())
|
|
184
184
|
.addColumn('owner_id', 'integer', (col) =>
|
|
185
185
|
col.references('person.id').onDelete('cascade')
|
|
@@ -200,6 +200,45 @@ export async function down(db: Kysely<any>): Promise<void> {
|
|
|
200
200
|
}
|
|
201
201
|
```
|
|
202
202
|
|
|
203
|
+
### MySQL migration example
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
import { Kysely } from 'kysely'
|
|
207
|
+
|
|
208
|
+
export async function up(db: Kysely<any>): Promise<void> {
|
|
209
|
+
await db.schema
|
|
210
|
+
.createTable('person')
|
|
211
|
+
.addColumn('id', 'integer', (col) => col.increments().primaryKey())
|
|
212
|
+
.addColumn('first_name', 'varchar')
|
|
213
|
+
.addColumn('last_name', 'varchar')
|
|
214
|
+
.addColumn('gender', 'varchar(50)')
|
|
215
|
+
.execute()
|
|
216
|
+
|
|
217
|
+
await db.schema
|
|
218
|
+
.createTable('pet')
|
|
219
|
+
.addColumn('id', 'integer', (col) => col.increments().primaryKey())
|
|
220
|
+
.addColumn('name', 'varchar', (col) => col.notNull().unique())
|
|
221
|
+
.addColumn('owner_id', 'integer')
|
|
222
|
+
.addColumn('species', 'varchar')
|
|
223
|
+
.addForeignKeyConstraint(
|
|
224
|
+
'pet_owner_id_fk', ['owner_id'], 'person', ['id'],
|
|
225
|
+
(cb) => cb.onDelete('cascade')
|
|
226
|
+
)
|
|
227
|
+
.execute()
|
|
228
|
+
|
|
229
|
+
await db.schema
|
|
230
|
+
.createIndex('pet_owner_id_index')
|
|
231
|
+
.on('pet')
|
|
232
|
+
.column('owner_id')
|
|
233
|
+
.execute()
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export async function down(db: Kysely<any>): Promise<void> {
|
|
237
|
+
await db.schema.dropTable('pet').execute()
|
|
238
|
+
await db.schema.dropTable('person').execute()
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
203
242
|
You can then use
|
|
204
243
|
|
|
205
244
|
```ts
|
|
@@ -11,6 +11,12 @@ class MysqlAdapter {
|
|
|
11
11
|
return false;
|
|
12
12
|
}
|
|
13
13
|
async acquireMigrationLock(db) {
|
|
14
|
+
// Kysely uses a single connection to run the migrations. Because of that, we
|
|
15
|
+
// can take a lock using `get_lock`. Locks acquired using `get_lock` get
|
|
16
|
+
// released when the connection is destroyed (session ends) or when the lock
|
|
17
|
+
// is released using `release_lock`. This way we know that the lock is either
|
|
18
|
+
// released by us after successfull or failed migrations OR it's released by
|
|
19
|
+
// mysql if the process gets killed for some reason.
|
|
14
20
|
await db
|
|
15
21
|
.raw(`select get_lock('${LOCK_ID}', ${LOCK_TIMEOUT_SECONDS})`)
|
|
16
22
|
.execute();
|
|
@@ -53,16 +53,16 @@ class MysqlDriver {
|
|
|
53
53
|
// On mysql this sets the isolation level of the next transaction.
|
|
54
54
|
await connection.executeQuery({
|
|
55
55
|
sql: `set transaction isolation level ${settings.isolationLevel}`,
|
|
56
|
-
|
|
56
|
+
parameters: [],
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
await connection.executeQuery({ sql: 'begin',
|
|
59
|
+
await connection.executeQuery({ sql: 'begin', parameters: [] });
|
|
60
60
|
}
|
|
61
61
|
async commitTransaction(connection) {
|
|
62
|
-
await connection.executeQuery({ sql: 'commit',
|
|
62
|
+
await connection.executeQuery({ sql: 'commit', parameters: [] });
|
|
63
63
|
}
|
|
64
64
|
async rollbackTransaction(connection) {
|
|
65
|
-
await connection.executeQuery({ sql: 'rollback',
|
|
65
|
+
await connection.executeQuery({ sql: 'rollback', parameters: [] });
|
|
66
66
|
}
|
|
67
67
|
async releaseConnection(connection) {
|
|
68
68
|
const mysqlConnection = connection;
|
|
@@ -131,7 +131,7 @@ class MysqlConnection {
|
|
|
131
131
|
}
|
|
132
132
|
#executeQuery(compiledQuery) {
|
|
133
133
|
return new Promise((resolve, reject) => {
|
|
134
|
-
this.#rawConnection.query(compiledQuery.sql, compiledQuery.
|
|
134
|
+
this.#rawConnection.query(compiledQuery.sql, compiledQuery.parameters, (err, result) => {
|
|
135
135
|
if (err) {
|
|
136
136
|
reject(err);
|
|
137
137
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { ColumnDefinitionNode } from '../../operation-node/column-definition-node.js';
|
|
2
1
|
import { DefaultQueryCompiler } from '../../query-compiler/default-query-compiler.js';
|
|
3
2
|
export declare class MysqlQueryCompiler extends DefaultQueryCompiler {
|
|
4
|
-
protected visitColumnDefinition(node: ColumnDefinitionNode): void;
|
|
5
3
|
protected visitReturning(): void;
|
|
6
4
|
protected getSql(): string;
|
|
7
5
|
protected getCurrentParameterPlaceholder(): string;
|
|
@@ -3,35 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MysqlQueryCompiler = void 0;
|
|
4
4
|
const default_query_compiler_js_1 = require("../../query-compiler/default-query-compiler.js");
|
|
5
5
|
class MysqlQueryCompiler extends default_query_compiler_js_1.DefaultQueryCompiler {
|
|
6
|
-
visitColumnDefinition(node) {
|
|
7
|
-
this.visitNode(node.column);
|
|
8
|
-
this.append(' ');
|
|
9
|
-
this.visitNode(node.dataType);
|
|
10
|
-
if (node.defaultTo) {
|
|
11
|
-
this.append(' default ');
|
|
12
|
-
this.visitNode(node.defaultTo);
|
|
13
|
-
}
|
|
14
|
-
if (!node.isNullable || node.isAutoIncrementing) {
|
|
15
|
-
this.append(' not null');
|
|
16
|
-
}
|
|
17
|
-
if (node.isAutoIncrementing) {
|
|
18
|
-
this.append(' auto_increment');
|
|
19
|
-
}
|
|
20
|
-
if (node.isUnique) {
|
|
21
|
-
this.append(' unique');
|
|
22
|
-
}
|
|
23
|
-
if (node.isPrimaryKey) {
|
|
24
|
-
this.append(' primary key');
|
|
25
|
-
}
|
|
26
|
-
if (node.references) {
|
|
27
|
-
this.append(' ');
|
|
28
|
-
this.visitNode(node.references);
|
|
29
|
-
}
|
|
30
|
-
if (node.check) {
|
|
31
|
-
this.append(' ');
|
|
32
|
-
this.visitNode(node.check);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
6
|
visitReturning() {
|
|
36
7
|
// Do nothing.
|
|
37
8
|
}
|
|
@@ -40,18 +40,18 @@ class PostgresDriver {
|
|
|
40
40
|
if (settings.isolationLevel) {
|
|
41
41
|
await connection.executeQuery({
|
|
42
42
|
sql: `start transaction isolation level ${settings.isolationLevel}`,
|
|
43
|
-
|
|
43
|
+
parameters: [],
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
|
-
await connection.executeQuery({ sql: 'begin',
|
|
47
|
+
await connection.executeQuery({ sql: 'begin', parameters: [] });
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
async commitTransaction(connection) {
|
|
51
|
-
await connection.executeQuery({ sql: 'commit',
|
|
51
|
+
await connection.executeQuery({ sql: 'commit', parameters: [] });
|
|
52
52
|
}
|
|
53
53
|
async rollbackTransaction(connection) {
|
|
54
|
-
await connection.executeQuery({ sql: 'rollback',
|
|
54
|
+
await connection.executeQuery({ sql: 'rollback', parameters: [] });
|
|
55
55
|
}
|
|
56
56
|
async releaseConnection(connection) {
|
|
57
57
|
const pgConnection = connection;
|
|
@@ -90,7 +90,7 @@ class PostgresConnection {
|
|
|
90
90
|
}
|
|
91
91
|
async executeQuery(compiledQuery) {
|
|
92
92
|
const result = await this.#client.query(compiledQuery.sql, [
|
|
93
|
-
...compiledQuery.
|
|
93
|
+
...compiledQuery.parameters,
|
|
94
94
|
]);
|
|
95
95
|
if (result.command === 'UPDATE' || result.command === 'DELETE') {
|
|
96
96
|
return {
|
|
@@ -12,7 +12,7 @@ exports.PrimitiveValueListNode = (0, object_utils_js_1.freeze)({
|
|
|
12
12
|
create(values) {
|
|
13
13
|
return (0, object_utils_js_1.freeze)({
|
|
14
14
|
kind: 'PrimitiveValueListNode',
|
|
15
|
-
values: (0, object_utils_js_1.freeze)(values),
|
|
15
|
+
values: (0, object_utils_js_1.freeze)([...values]),
|
|
16
16
|
});
|
|
17
17
|
},
|
|
18
18
|
});
|
|
@@ -9,7 +9,7 @@ export declare type InsertObject<DB, TB extends keyof DB> = {
|
|
|
9
9
|
[C in keyof DB[TB]]: InsertValueExpression<DB[TB][C]>;
|
|
10
10
|
};
|
|
11
11
|
export declare type InsertObjectOrList<DB, TB extends keyof DB> = InsertObject<DB, TB> | InsertObject<DB, TB>[];
|
|
12
|
-
declare type InsertValueExpression<T
|
|
12
|
+
declare type InsertValueExpression<T> = T | AnyQueryBuilder | AnyRawBuilder | GeneratedPlaceholder;
|
|
13
13
|
export declare function parseInsertObjectOrList(args: InsertObjectOrList<any, any>): [ReadonlyArray<ColumnNode>, ReadonlyArray<InsertValuesNode>];
|
|
14
14
|
export declare function parseInsertValueExpression(value: InsertValueExpression<PrimitiveValue>): ValueNode | RawNode | SelectQueryNode;
|
|
15
15
|
export {};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { JoinNode, JoinType } from '../operation-node/join-node.js';
|
|
2
2
|
import { AnyColumn, AnyColumnWithTable } from '../util/type-utils.js';
|
|
3
|
-
import { ExtractAliasFromTableExpression,
|
|
3
|
+
import { ExtractAliasFromTableExpression, TableExpressionDatabase } from './table-parser.js';
|
|
4
4
|
import { JoinBuilder } from '../query-builder/join-builder.js';
|
|
5
5
|
import { ParseContext } from './parse-context.js';
|
|
6
|
-
export declare type JoinReferenceExpression<DB, TB extends keyof DB, F> =
|
|
7
|
-
export declare type JoinCallbackExpression<DB, TB extends keyof DB, F> = (join: JoinBuilder<
|
|
6
|
+
export declare type JoinReferenceExpression<DB, TB extends keyof DB, F> = AnyJoinColumn<DB, TB, F> | AnyJoinColumnWithTable<DB, TB, F>;
|
|
7
|
+
export declare type JoinCallbackExpression<DB, TB extends keyof DB, F> = (join: JoinBuilder<TableExpressionDatabase<DB, F>, TB | ExtractAliasFromTableExpression<DB, F>>) => JoinBuilder<any, any>;
|
|
8
|
+
declare type AnyJoinColumn<DB, TB extends keyof DB, F> = AnyColumn<TableExpressionDatabase<DB, F>, TB | ExtractAliasFromTableExpression<DB, F>>;
|
|
9
|
+
declare type AnyJoinColumnWithTable<DB, TB extends keyof DB, F> = AnyColumnWithTable<TableExpressionDatabase<DB, F>, TB | ExtractAliasFromTableExpression<DB, F>>;
|
|
8
10
|
export declare function parseJoin(ctx: ParseContext, joinType: JoinType, args: any[]): JoinNode;
|
|
11
|
+
export {};
|
|
@@ -1,21 +1,32 @@
|
|
|
1
1
|
import { AliasedQueryBuilder, QueryBuilder } from '../query-builder/query-builder.js';
|
|
2
2
|
import { TableNode } from '../operation-node/table-node.js';
|
|
3
|
-
import { AliasedQueryBuilderFactory, AnyAliasedQueryBuilder, AnyAliasedRawBuilder } from '../util/type-utils.js';
|
|
3
|
+
import { AliasedQueryBuilderFactory, AnyAliasedQueryBuilder, AnyAliasedRawBuilder, Nullable } from '../util/type-utils.js';
|
|
4
4
|
import { AliasedRawBuilder } from '../raw-builder/raw-builder.js';
|
|
5
5
|
import { TableExpressionNode } from '../operation-node/operation-node-utils.js';
|
|
6
6
|
import { ParseContext } from './parse-context.js';
|
|
7
7
|
export declare type TableExpression<DB, TB extends keyof DB> = TableReference<DB> | AnyAliasedQueryBuilder | AliasedQueryBuilderFactory<DB, TB>;
|
|
8
8
|
export declare type TableExpressionOrList<DB, TB extends keyof DB> = TableExpression<DB, TB> | ReadonlyArray<TableExpression<DB, TB>>;
|
|
9
9
|
export declare type TableReference<DB> = AnyAliasedTable<DB, any, any> | AnyTable<DB> | AnyAliasedRawBuilder;
|
|
10
|
-
export declare type QueryBuilderWithTable<DB, TB extends keyof DB, O, TE> = QueryBuilder<
|
|
11
|
-
export declare type
|
|
10
|
+
export declare type QueryBuilderWithTable<DB, TB extends keyof DB, O, TE> = QueryBuilder<TableExpressionDatabase<DB, TE>, TB | ExtractAliasFromTableExpression<DB, TE>, O>;
|
|
11
|
+
export declare type TableExpressionDatabase<DB, TE, A extends keyof any = ExtractAliasFromTableExpression<DB, TE>> = {
|
|
12
|
+
[C in keyof DB | A]: C extends A ? ExtractRowTypeFromTableExpression<DB, TE, C> : C extends keyof DB ? DB[C] : never;
|
|
13
|
+
};
|
|
14
|
+
export declare type QueryBuilderWithLeftJoin<DB, TB extends keyof DB, O, TE> = QueryBuilder<LeftJoinTableExpressionDatabase<DB, TE>, TB | ExtractAliasFromTableExpression<DB, TE>, O>;
|
|
15
|
+
export declare type LeftJoinTableExpressionDatabase<DB, TE, A extends keyof any = ExtractAliasFromTableExpression<DB, TE>> = {
|
|
16
|
+
[C in keyof DB | A]: C extends A ? Nullable<ExtractRowTypeFromTableExpression<DB, TE, C>> : C extends keyof DB ? DB[C] : never;
|
|
17
|
+
};
|
|
18
|
+
export declare type QueryBuilderWithRightJoin<DB, TB extends keyof DB, O, TE> = QueryBuilder<RightJoinTableExpressionDatabase<DB, TB, TE>, TB | ExtractAliasFromTableExpression<DB, TE>, O>;
|
|
19
|
+
export declare type RightJoinTableExpressionDatabase<DB, TB extends keyof DB, TE, A extends keyof any = ExtractAliasFromTableExpression<DB, TE>> = {
|
|
20
|
+
[C in keyof DB | A]: C extends A ? ExtractRowTypeFromTableExpression<DB, TE, C> : C extends keyof DB ? C extends TB ? Nullable<DB[C]> : DB[C] : never;
|
|
21
|
+
};
|
|
22
|
+
export declare type QueryBuilderWithFullJoin<DB, TB extends keyof DB, O, TE> = QueryBuilder<FullJoinTableExpressionDatabase<DB, TB, TE>, TB | ExtractAliasFromTableExpression<DB, TE>, O>;
|
|
23
|
+
export declare type FullJoinTableExpressionDatabase<DB, TB extends keyof DB, TE, A extends keyof any = ExtractAliasFromTableExpression<DB, TE>> = {
|
|
24
|
+
[C in keyof DB | A]: C extends A ? Nullable<ExtractRowTypeFromTableExpression<DB, TE, C>> : C extends keyof DB ? C extends TB ? Nullable<DB[C]> : DB[C] : never;
|
|
25
|
+
};
|
|
12
26
|
export declare type ExtractAliasFromTableExpression<DB, TE> = TE extends `${string} as ${infer TA}` ? TA : TE extends keyof DB ? TE : TE extends AliasedQueryBuilder<any, any, any, infer QA> ? QA : TE extends (qb: any) => AliasedQueryBuilder<any, any, any, infer QA> ? QA : TE extends AliasedRawBuilder<any, infer RA> ? RA : TE extends (qb: any) => AliasedRawBuilder<any, infer RA> ? RA : never;
|
|
27
|
+
declare type ExtractRowTypeFromTableExpression<DB, TE, A extends keyof any> = TE extends `${infer T} as ${infer TA}` ? TA extends A ? T extends keyof DB ? DB[T] : never : never : TE extends A ? TE extends keyof DB ? DB[TE] : never : TE extends AliasedQueryBuilder<any, any, infer O, infer QA> ? QA extends A ? O : never : TE extends (qb: any) => AliasedQueryBuilder<any, any, infer O, infer QA> ? QA extends A ? O : never : TE extends AliasedRawBuilder<infer O, infer RA> ? RA extends A ? O : never : never;
|
|
13
28
|
declare type AnyAliasedTable<DB, TB extends keyof DB, A extends string> = TB extends string ? `${TB} as ${A}` : never;
|
|
14
29
|
declare type AnyTable<DB> = keyof DB;
|
|
15
|
-
declare type ExtractDatabaseTypeFromTableExpression<DB, TE> = {
|
|
16
|
-
[A in ExtractAliasFromTableExpression<DB, TE>]: ExtractRowTypeFromTableExpression<DB, TE, A>;
|
|
17
|
-
};
|
|
18
|
-
declare type ExtractRowTypeFromTableExpression<DB, TE, A extends keyof any> = TE extends `${infer T} as ${infer TA}` ? TA extends A ? T extends keyof DB ? DB[T] : never : never : TE extends A ? TE extends keyof DB ? DB[TE] : never : TE extends AliasedQueryBuilder<any, any, infer O, infer QA> ? QA extends A ? O : never : TE extends (qb: any) => AliasedQueryBuilder<any, any, infer O, infer QA> ? QA extends A ? O : never : TE extends AliasedRawBuilder<infer O, infer RA> ? RA extends A ? O : never : never;
|
|
19
30
|
export declare function parseTableExpressionOrList(ctx: ParseContext, table: TableExpressionOrList<any, any>): TableExpressionNode[];
|
|
20
31
|
export declare function parseTableExpression(ctx: ParseContext, table: TableExpression<any, any>): TableExpressionNode;
|
|
21
32
|
export declare function parseAliasedTable(from: string): TableExpressionNode;
|
|
@@ -8,6 +8,6 @@ import { ParseContext } from './parse-context.js';
|
|
|
8
8
|
export declare type MutationObject<DB, TB extends keyof DB> = {
|
|
9
9
|
[C in keyof DB[TB]]?: MutationValueExpression<DB, TB, DB[TB][C]>;
|
|
10
10
|
};
|
|
11
|
-
export declare type MutationValueExpression<DB, TB extends keyof DB, T
|
|
11
|
+
export declare type MutationValueExpression<DB, TB extends keyof DB, T> = T | AnyQueryBuilder | QueryBuilderFactory<DB, TB> | AnyRawBuilder | RawBuilderFactory<DB, TB>;
|
|
12
12
|
export declare function parseUpdateObject(ctx: ParseContext, row: MutationObject<any, any>): ReadonlyArray<ColumnUpdateNode>;
|
|
13
13
|
export declare function parseMutationValueExpression(ctx: ParseContext, value: MutationValueExpression<any, any, PrimitiveValue>): ValueNode | RawNode | SelectQueryNode;
|
|
@@ -66,9 +66,9 @@ export declare class FunctionBuilder<DB, TB extends keyof DB> {
|
|
|
66
66
|
* Calls the `sum` function for the column given as the argument.
|
|
67
67
|
*
|
|
68
68
|
* If this is used in a `select` statement the type of the selected expression
|
|
69
|
-
* will be `number | string` by default. This is because Kysely can't
|
|
70
|
-
* type the db driver outputs. Sometimes the output can be larger than
|
|
71
|
-
* largest javascript number and a string is returned instead. Most drivers
|
|
69
|
+
* will be `number | string | BigInt` by default. This is because Kysely can't
|
|
70
|
+
* know the type the db driver outputs. Sometimes the output can be larger than
|
|
71
|
+
* the largest javascript number and a string is returned instead. Most drivers
|
|
72
72
|
* allow you to configure the output type of large numbers and Kysely can't
|
|
73
73
|
* know if you've done so.
|
|
74
74
|
*
|
|
@@ -88,9 +88,9 @@ export declare class FunctionBuilder<DB, TB extends keyof DB> {
|
|
|
88
88
|
* Calls the `count` function for the column given as the argument.
|
|
89
89
|
*
|
|
90
90
|
* If this is used in a `select` statement the type of the selected expression
|
|
91
|
-
* will be `number | string` by default. This is because Kysely can't
|
|
92
|
-
* type the db driver outputs. Sometimes the output can be larger than
|
|
93
|
-
* largest javascript number and a string is returned instead. Most drivers
|
|
91
|
+
* will be `number | string | BigInt` by default. This is because Kysely can't
|
|
92
|
+
* know the type the db driver outputs. Sometimes the output can be larger than
|
|
93
|
+
* the largest javascript number and a string is returned instead. Most drivers
|
|
94
94
|
* allow you to configure the output type of large numbers and Kysely can't
|
|
95
95
|
* know if you've done so.
|
|
96
96
|
*
|
|
@@ -82,9 +82,9 @@ class FunctionBuilder {
|
|
|
82
82
|
* Calls the `sum` function for the column given as the argument.
|
|
83
83
|
*
|
|
84
84
|
* If this is used in a `select` statement the type of the selected expression
|
|
85
|
-
* will be `number | string` by default. This is because Kysely can't
|
|
86
|
-
* type the db driver outputs. Sometimes the output can be larger than
|
|
87
|
-
* largest javascript number and a string is returned instead. Most drivers
|
|
85
|
+
* will be `number | string | BigInt` by default. This is because Kysely can't
|
|
86
|
+
* know the type the db driver outputs. Sometimes the output can be larger than
|
|
87
|
+
* the largest javascript number and a string is returned instead. Most drivers
|
|
88
88
|
* allow you to configure the output type of large numbers and Kysely can't
|
|
89
89
|
* know if you've done so.
|
|
90
90
|
*
|
|
@@ -106,9 +106,9 @@ class FunctionBuilder {
|
|
|
106
106
|
* Calls the `count` function for the column given as the argument.
|
|
107
107
|
*
|
|
108
108
|
* If this is used in a `select` statement the type of the selected expression
|
|
109
|
-
* will be `number | string` by default. This is because Kysely can't
|
|
110
|
-
* type the db driver outputs. Sometimes the output can be larger than
|
|
111
|
-
* largest javascript number and a string is returned instead. Most drivers
|
|
109
|
+
* will be `number | string | BigInt` by default. This is because Kysely can't
|
|
110
|
+
* know the type the db driver outputs. Sometimes the output can be larger than
|
|
111
|
+
* the largest javascript number and a string is returned instead. Most drivers
|
|
112
112
|
* allow you to configure the output type of large numbers and Kysely can't
|
|
113
113
|
* know if you've done so.
|
|
114
114
|
*
|
|
@@ -131,7 +131,7 @@ class FunctionBuilder {
|
|
|
131
131
|
queryId: (0, query_id_js_1.createQueryId)(),
|
|
132
132
|
executor: this.#props.executor,
|
|
133
133
|
sql: `${fn}(??)`,
|
|
134
|
-
|
|
134
|
+
parameters: [column],
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
137
|
}
|
|
@@ -2,7 +2,7 @@ import { AliasNode } from '../operation-node/alias-node.js';
|
|
|
2
2
|
import { OperationNodeSource } from '../operation-node/operation-node-source.js';
|
|
3
3
|
import { CompiledQuery } from '../query-compiler/compiled-query.js';
|
|
4
4
|
import { JoinCallbackExpression, JoinReferenceExpression } from '../parser/join-parser.js';
|
|
5
|
-
import { TableExpression, QueryBuilderWithTable } from '../parser/table-parser.js';
|
|
5
|
+
import { TableExpression, QueryBuilderWithTable, QueryBuilderWithLeftJoin, QueryBuilderWithRightJoin, QueryBuilderWithFullJoin } from '../parser/table-parser.js';
|
|
6
6
|
import { SelectExpression, QueryBuilderWithSelection, SelectAllQueryBuilder } from '../parser/select-parser.js';
|
|
7
7
|
import { ExistsExpression, FilterOperator } from '../parser/filter-parser.js';
|
|
8
8
|
import { InsertObject } from '../parser/insert-values-parser.js';
|
|
@@ -869,20 +869,20 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
|
|
|
869
869
|
* Just like {@link QueryBuilder.innerJoin | innerJoin} but adds a left join
|
|
870
870
|
* instead of an inner join.
|
|
871
871
|
*/
|
|
872
|
-
leftJoin<TE extends TableExpression<DB, TB>, K1 extends JoinReferenceExpression<DB, TB, TE>, K2 extends JoinReferenceExpression<DB, TB, TE>>(table: TE, k1: K1, k2: K2):
|
|
873
|
-
leftJoin<TE extends TableExpression<DB, TB>, FN extends JoinCallbackExpression<DB, TB, TE>>(table: TE, callback: FN):
|
|
872
|
+
leftJoin<TE extends TableExpression<DB, TB>, K1 extends JoinReferenceExpression<DB, TB, TE>, K2 extends JoinReferenceExpression<DB, TB, TE>>(table: TE, k1: K1, k2: K2): QueryBuilderWithLeftJoin<DB, TB, O, TE>;
|
|
873
|
+
leftJoin<TE extends TableExpression<DB, TB>, FN extends JoinCallbackExpression<DB, TB, TE>>(table: TE, callback: FN): QueryBuilderWithLeftJoin<DB, TB, O, TE>;
|
|
874
874
|
/**
|
|
875
875
|
* Just like {@link QueryBuilder.innerJoin | innerJoin} but adds a right join
|
|
876
876
|
* instead of an inner join.
|
|
877
877
|
*/
|
|
878
|
-
rightJoin<TE extends TableExpression<DB, TB>, K1 extends JoinReferenceExpression<DB, TB, TE>, K2 extends JoinReferenceExpression<DB, TB, TE>>(table: TE, k1: K1, k2: K2):
|
|
879
|
-
rightJoin<TE extends TableExpression<DB, TB>, FN extends JoinCallbackExpression<DB, TB, TE>>(table: TE, callback: FN):
|
|
878
|
+
rightJoin<TE extends TableExpression<DB, TB>, K1 extends JoinReferenceExpression<DB, TB, TE>, K2 extends JoinReferenceExpression<DB, TB, TE>>(table: TE, k1: K1, k2: K2): QueryBuilderWithRightJoin<DB, TB, O, TE>;
|
|
879
|
+
rightJoin<TE extends TableExpression<DB, TB>, FN extends JoinCallbackExpression<DB, TB, TE>>(table: TE, callback: FN): QueryBuilderWithRightJoin<DB, TB, O, TE>;
|
|
880
880
|
/**
|
|
881
881
|
* Just like {@link QueryBuilder.innerJoin | innerJoin} but adds a full join
|
|
882
882
|
* instead of an inner join.
|
|
883
883
|
*/
|
|
884
|
-
fullJoin<TE extends TableExpression<DB, TB>, K1 extends JoinReferenceExpression<DB, TB, TE>, K2 extends JoinReferenceExpression<DB, TB, TE>>(table: TE, k1: K1, k2: K2):
|
|
885
|
-
fullJoin<TE extends TableExpression<DB, TB>, FN extends JoinCallbackExpression<DB, TB, TE>>(table: TE, callback: FN):
|
|
884
|
+
fullJoin<TE extends TableExpression<DB, TB>, K1 extends JoinReferenceExpression<DB, TB, TE>, K2 extends JoinReferenceExpression<DB, TB, TE>>(table: TE, k1: K1, k2: K2): QueryBuilderWithFullJoin<DB, TB, O, TE>;
|
|
885
|
+
fullJoin<TE extends TableExpression<DB, TB>, FN extends JoinCallbackExpression<DB, TB, TE>>(table: TE, callback: FN): QueryBuilderWithFullJoin<DB, TB, O, TE>;
|
|
886
886
|
/**
|
|
887
887
|
* Sets the values to insert for an {@link Kysely.insertInto | insert} query.
|
|
888
888
|
*
|
|
@@ -62,7 +62,7 @@ import { ModifyColumnNode } from '../operation-node/modify-column-node.js';
|
|
|
62
62
|
import { OnDuplicateKeyNode } from '../operation-node/on-duplicate-key-node.js';
|
|
63
63
|
export declare class DefaultQueryCompiler extends OperationNodeVisitor implements QueryCompiler {
|
|
64
64
|
#private;
|
|
65
|
-
protected get
|
|
65
|
+
protected get numParameters(): number;
|
|
66
66
|
compileQuery(node: RootOperationNode): CompiledQuery;
|
|
67
67
|
protected getSql(): string;
|
|
68
68
|
protected visitSelectQuery(node: SelectQueryNode): void;
|
|
@@ -92,6 +92,7 @@ export declare class DefaultQueryCompiler extends OperationNodeVisitor implement
|
|
|
92
92
|
protected visitTable(node: TableNode): void;
|
|
93
93
|
protected visitCreateTable(node: CreateTableNode): void;
|
|
94
94
|
protected visitColumnDefinition(node: ColumnDefinitionNode): void;
|
|
95
|
+
protected getAutoIncrement(): string;
|
|
95
96
|
protected visitReferences(node: ReferencesNode): void;
|
|
96
97
|
protected visitDropTable(node: DropTableNode): void;
|
|
97
98
|
protected visitDataType(node: DataTypeNode): void;
|
|
@@ -129,6 +130,6 @@ export declare class DefaultQueryCompiler extends OperationNodeVisitor implement
|
|
|
129
130
|
protected getLeftIdentifierWrapper(): string;
|
|
130
131
|
protected getRightIdentifierWrapper(): string;
|
|
131
132
|
protected getCurrentParameterPlaceholder(): string;
|
|
132
|
-
protected
|
|
133
|
+
protected addParameter(parameter: any): void;
|
|
133
134
|
protected appendImmediateValue(value: PrimitiveValue): void;
|
|
134
135
|
}
|
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DefaultQueryCompiler = void 0;
|
|
4
|
-
const data_type_node_js_1 = require("../operation-node/data-type-node.js");
|
|
5
4
|
const operation_node_visitor_js_1 = require("../operation-node/operation-node-visitor.js");
|
|
6
5
|
const query_node_js_1 = require("../operation-node/query-node.js");
|
|
7
6
|
const raw_node_js_1 = require("../operation-node/raw-node.js");
|
|
8
7
|
const object_utils_js_1 = require("../util/object-utils.js");
|
|
9
8
|
class DefaultQueryCompiler extends operation_node_visitor_js_1.OperationNodeVisitor {
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
get
|
|
13
|
-
return this.#
|
|
9
|
+
#sql = '';
|
|
10
|
+
#parameters = [];
|
|
11
|
+
get numParameters() {
|
|
12
|
+
return this.#parameters.length;
|
|
14
13
|
}
|
|
15
14
|
compileQuery(node) {
|
|
16
|
-
this.#
|
|
17
|
-
this.#
|
|
15
|
+
this.#sql = '';
|
|
16
|
+
this.#parameters = [];
|
|
18
17
|
this.visitNode(node);
|
|
19
18
|
return (0, object_utils_js_1.freeze)({
|
|
20
19
|
sql: this.getSql(),
|
|
21
|
-
|
|
20
|
+
parameters: this.#parameters,
|
|
22
21
|
});
|
|
23
22
|
}
|
|
24
23
|
getSql() {
|
|
25
|
-
return this.#
|
|
24
|
+
return this.#sql;
|
|
26
25
|
}
|
|
27
26
|
visitSelectQuery(node) {
|
|
28
27
|
// This is a sub query if this is not the root node.
|
|
@@ -292,19 +291,7 @@ class DefaultQueryCompiler extends operation_node_visitor_js_1.OperationNodeVisi
|
|
|
292
291
|
visitColumnDefinition(node) {
|
|
293
292
|
this.visitNode(node.column);
|
|
294
293
|
this.append(' ');
|
|
295
|
-
|
|
296
|
-
// Postgres overrides the data type for autoincrementing columns.
|
|
297
|
-
if (data_type_node_js_1.DataTypeNode.is(node.dataType) &&
|
|
298
|
-
node.dataType.dataType === 'bigint') {
|
|
299
|
-
this.append('bigserial');
|
|
300
|
-
}
|
|
301
|
-
else {
|
|
302
|
-
this.append('serial');
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
else {
|
|
306
|
-
this.visitNode(node.dataType);
|
|
307
|
-
}
|
|
294
|
+
this.visitNode(node.dataType);
|
|
308
295
|
if (node.defaultTo) {
|
|
309
296
|
this.append(' default ');
|
|
310
297
|
this.visitNode(node.defaultTo);
|
|
@@ -312,6 +299,10 @@ class DefaultQueryCompiler extends operation_node_visitor_js_1.OperationNodeVisi
|
|
|
312
299
|
if (!node.isNullable) {
|
|
313
300
|
this.append(' not null');
|
|
314
301
|
}
|
|
302
|
+
if (node.isAutoIncrementing) {
|
|
303
|
+
this.append(' ');
|
|
304
|
+
this.append(this.getAutoIncrement());
|
|
305
|
+
}
|
|
315
306
|
if (node.isUnique) {
|
|
316
307
|
this.append(' unique');
|
|
317
308
|
}
|
|
@@ -327,6 +318,9 @@ class DefaultQueryCompiler extends operation_node_visitor_js_1.OperationNodeVisi
|
|
|
327
318
|
this.visitNode(node.check);
|
|
328
319
|
}
|
|
329
320
|
}
|
|
321
|
+
getAutoIncrement() {
|
|
322
|
+
return 'auto_increment';
|
|
323
|
+
}
|
|
330
324
|
visitReferences(node) {
|
|
331
325
|
this.append('references ');
|
|
332
326
|
this.visitNode(node.table);
|
|
@@ -637,10 +631,10 @@ class DefaultQueryCompiler extends operation_node_visitor_js_1.OperationNodeVisi
|
|
|
637
631
|
this.visitNode(node.constraintName);
|
|
638
632
|
}
|
|
639
633
|
append(str) {
|
|
640
|
-
this.#
|
|
634
|
+
this.#sql += str;
|
|
641
635
|
}
|
|
642
636
|
appendValue(value) {
|
|
643
|
-
this.
|
|
637
|
+
this.addParameter(value);
|
|
644
638
|
this.append(this.getCurrentParameterPlaceholder());
|
|
645
639
|
}
|
|
646
640
|
getLeftIdentifierWrapper() {
|
|
@@ -650,10 +644,10 @@ class DefaultQueryCompiler extends operation_node_visitor_js_1.OperationNodeVisi
|
|
|
650
644
|
return '"';
|
|
651
645
|
}
|
|
652
646
|
getCurrentParameterPlaceholder() {
|
|
653
|
-
return '$' + this.
|
|
647
|
+
return '$' + this.numParameters;
|
|
654
648
|
}
|
|
655
|
-
|
|
656
|
-
this.#
|
|
649
|
+
addParameter(parameter) {
|
|
650
|
+
this.#parameters.push(parameter);
|
|
657
651
|
}
|
|
658
652
|
appendImmediateValue(value) {
|
|
659
653
|
if ((0, object_utils_js_1.isString)(value)) {
|
|
@@ -10,7 +10,7 @@ export declare class QueryCreator<DB> {
|
|
|
10
10
|
#private;
|
|
11
11
|
constructor(props: QueryCreatorProps);
|
|
12
12
|
/**
|
|
13
|
-
* Creates a `select` query builder
|
|
13
|
+
* Creates a `select` query builder for the given table or tables.
|
|
14
14
|
*
|
|
15
15
|
* The tables passed to this method are built as the query's `from` clause.
|
|
16
16
|
*
|
|
@@ -221,6 +221,9 @@ export declare class QueryCreator<DB> {
|
|
|
221
221
|
* Sets the schema to be used for all table references that don't explicitly
|
|
222
222
|
* specify a schema.
|
|
223
223
|
*
|
|
224
|
+
* This only affects the query created through the builder returned from
|
|
225
|
+
* this method and doesn't modify the `db` instance.
|
|
226
|
+
*
|
|
224
227
|
* @example
|
|
225
228
|
* ```
|
|
226
229
|
* await db.withSchema('mammals')
|
|
@@ -261,10 +264,10 @@ export declare class QueryCreator<DB> {
|
|
|
261
264
|
* Provides a way to pass arbitrary SQL into your query and executing completely
|
|
262
265
|
* raw queries.
|
|
263
266
|
*
|
|
264
|
-
* You can use strings `?` and `??` in the `sql` to bind parameters such as
|
|
267
|
+
* You can use the strings `?` and `??` in the `sql` to bind parameters such as
|
|
265
268
|
* user input to the SQL. You should never EVER concatenate untrusted user
|
|
266
269
|
* input to the SQL string to avoid injection vulnerabilities. Instead use `?`
|
|
267
|
-
* in place of
|
|
270
|
+
* in place of a value and pass the actual value in the `parameters` list. See
|
|
268
271
|
* the examples below.
|
|
269
272
|
*
|
|
270
273
|
* You should only use `raw` when there is no other way to get the job done. This is
|
|
@@ -276,11 +279,11 @@ export declare class QueryCreator<DB> {
|
|
|
276
279
|
* Raw builder instances can be passed to pretty much anywhere: `select`, `where`,
|
|
277
280
|
* `*Join`, `groupBy`, `orderBy` etc. Just try it. If the method accepts it, it works.
|
|
278
281
|
*
|
|
279
|
-
* @param sql - The raw SQL. Special strings `?` and `??` can be used
|
|
280
|
-
*
|
|
282
|
+
* @param sql - The raw SQL. Special strings `?` and `??` can be used as parameter
|
|
283
|
+
* placeholders. `?` for values and `??` for identifiers such as column names
|
|
281
284
|
* or `column.table` references.
|
|
282
285
|
*
|
|
283
|
-
* @param params - The parameters that will be bound to the `?` and `??`
|
|
286
|
+
* @param params - The parameters that will be bound to the `?` and `??` placeholders in
|
|
284
287
|
* the sql string.
|
|
285
288
|
*
|
|
286
289
|
* @example
|
|
@@ -318,7 +321,7 @@ export declare class QueryCreator<DB> {
|
|
|
318
321
|
* the output type. In this case you need to use the `castTo` method on the query
|
|
319
322
|
* to specify a return type for the query.
|
|
320
323
|
*
|
|
321
|
-
* We could've also used `??`
|
|
324
|
+
* We could've also used a `??` placeholder to provide `first_name` and `last_name` like
|
|
322
325
|
* this:
|
|
323
326
|
*
|
|
324
327
|
* ```ts
|
|
@@ -333,9 +336,9 @@ export declare class QueryCreator<DB> {
|
|
|
333
336
|
*
|
|
334
337
|
* But it's often cleaner to just write the column names in the SQL. Again remember to
|
|
335
338
|
* never concatenate column names or any other untrusted user input to the SQL string or you
|
|
336
|
-
* are going to create an injection vulnerability. All user input should go to the
|
|
339
|
+
* are going to create an injection vulnerability. All user input should go to the parameters
|
|
337
340
|
* array, never to the SQL string directly. But if the column names or values are trusted
|
|
338
|
-
* and known at compile time, there is no reason to use
|
|
341
|
+
* and known at compile time, there is no reason to use parameters.
|
|
339
342
|
*
|
|
340
343
|
* @example
|
|
341
344
|
* Example of using `raw` in `where`:
|
|
@@ -361,7 +364,7 @@ export declare class QueryCreator<DB> {
|
|
|
361
364
|
*
|
|
362
365
|
* The function in the above example returns people that are older than the given number of
|
|
363
366
|
* years. The number of years in this example is an untrusted user input, and therefore we use
|
|
364
|
-
* a `?`
|
|
367
|
+
* a `?` placeholder for it.
|
|
365
368
|
*
|
|
366
369
|
* @example
|
|
367
370
|
* Example of creating a completely raw query from scratch:
|
|
@@ -375,7 +378,7 @@ export declare class QueryCreator<DB> {
|
|
|
375
378
|
* The result of `execute()` method is always an array. In this case the type of
|
|
376
379
|
* the `persons` variable is `Person[]`.
|
|
377
380
|
*/
|
|
378
|
-
raw<T = unknown>(sql: string,
|
|
381
|
+
raw<T = unknown>(sql: string, parameters?: any[]): RawBuilder<T>;
|
|
379
382
|
}
|
|
380
383
|
export interface QueryCreatorProps {
|
|
381
384
|
readonly executor: QueryExecutor;
|