kysely 0.18.1 → 0.19.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 +22 -17
- package/dist/cjs/dialect/mysql/mysql-dialect-config.d.ts +24 -207
- package/dist/cjs/dialect/mysql/mysql-dialect.d.ts +22 -7
- package/dist/cjs/dialect/mysql/mysql-dialect.js +25 -9
- package/dist/cjs/dialect/mysql/mysql-driver.d.ts +2 -15
- package/dist/cjs/dialect/mysql/mysql-driver.js +4 -35
- package/dist/cjs/dialect/postgres/postgres-dialect-config.d.ts +25 -89
- package/dist/cjs/dialect/postgres/postgres-dialect.d.ts +21 -9
- package/dist/cjs/dialect/postgres/postgres-dialect.js +24 -11
- package/dist/cjs/dialect/postgres/postgres-driver.d.ts +2 -15
- package/dist/cjs/dialect/postgres/postgres-driver.js +5 -36
- package/dist/cjs/dialect/sqlite/sqlite-dialect-config.d.ts +25 -28
- package/dist/cjs/dialect/sqlite/sqlite-dialect.d.ts +19 -3
- package/dist/cjs/dialect/sqlite/sqlite-dialect.js +19 -3
- package/dist/cjs/dialect/sqlite/sqlite-driver.js +3 -37
- package/dist/cjs/index.d.ts +153 -2
- package/dist/cjs/index.js +142 -2
- package/dist/cjs/migration/file-migration-provider.d.ts +21 -5
- package/dist/cjs/migration/file-migration-provider.js +14 -13
- package/dist/cjs/plugin/noop-plugin.d.ts +1 -1
- package/dist/esm/dialect/mysql/mysql-dialect-config.d.ts +24 -207
- package/dist/esm/dialect/mysql/mysql-dialect.d.ts +22 -7
- package/dist/esm/dialect/mysql/mysql-dialect.js +25 -9
- package/dist/esm/dialect/mysql/mysql-driver.d.ts +2 -15
- package/dist/esm/dialect/mysql/mysql-driver.js +4 -35
- package/dist/esm/dialect/postgres/postgres-dialect-config.d.ts +25 -89
- package/dist/esm/dialect/postgres/postgres-dialect.d.ts +21 -9
- package/dist/esm/dialect/postgres/postgres-dialect.js +24 -11
- package/dist/esm/dialect/postgres/postgres-driver.d.ts +2 -15
- package/dist/esm/dialect/postgres/postgres-driver.js +6 -37
- package/dist/esm/dialect/sqlite/sqlite-dialect-config.d.ts +25 -28
- package/dist/esm/dialect/sqlite/sqlite-dialect.d.ts +19 -3
- package/dist/esm/dialect/sqlite/sqlite-dialect.js +19 -3
- package/dist/esm/dialect/sqlite/sqlite-driver.js +4 -38
- package/dist/esm/index.d.ts +153 -2
- package/dist/esm/index.js +142 -2
- package/dist/esm/migration/file-migration-provider.d.ts +21 -5
- package/dist/esm/migration/file-migration-provider.js +14 -13
- package/dist/esm/plugin/noop-plugin.d.ts +1 -1
- package/package.json +2 -7
- package/dist/cjs/index-nodeless.d.ts +0 -152
- package/dist/cjs/index-nodeless.js +0 -157
- package/dist/esm/index-nodeless.d.ts +0 -152
- package/dist/esm/index-nodeless.js +0 -142
package/dist/cjs/index.js
CHANGED
|
@@ -14,14 +14,154 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./kysely.js"), exports);
|
|
18
|
+
__exportStar(require("./query-creator.js"), exports);
|
|
19
|
+
__exportStar(require("./query-builder/where-interface.js"), exports);
|
|
20
|
+
__exportStar(require("./query-builder/join-interface.js"), exports);
|
|
21
|
+
__exportStar(require("./query-builder/returning-interface.js"), exports);
|
|
22
|
+
__exportStar(require("./query-builder/having-interface.js"), exports);
|
|
23
|
+
__exportStar(require("./query-builder/select-query-builder.js"), exports);
|
|
24
|
+
__exportStar(require("./query-builder/insert-query-builder.js"), exports);
|
|
25
|
+
__exportStar(require("./query-builder/update-query-builder.js"), exports);
|
|
26
|
+
__exportStar(require("./query-builder/delete-query-builder.js"), exports);
|
|
27
|
+
__exportStar(require("./query-builder/no-result-error.js"), exports);
|
|
28
|
+
__exportStar(require("./query-builder/join-builder.js"), exports);
|
|
29
|
+
__exportStar(require("./query-builder/expression-builder.js"), exports);
|
|
30
|
+
__exportStar(require("./query-builder/function-builder.js"), exports);
|
|
31
|
+
__exportStar(require("./query-builder/insert-result.js"), exports);
|
|
32
|
+
__exportStar(require("./query-builder/delete-result.js"), exports);
|
|
33
|
+
__exportStar(require("./query-builder/update-result.js"), exports);
|
|
34
|
+
__exportStar(require("./query-builder/on-conflict-builder.js"), exports);
|
|
35
|
+
__exportStar(require("./raw-builder/raw-builder.js"), exports);
|
|
36
|
+
__exportStar(require("./raw-builder/sql.js"), exports);
|
|
37
|
+
__exportStar(require("./query-executor/query-executor.js"), exports);
|
|
38
|
+
__exportStar(require("./query-executor/default-query-executor.js"), exports);
|
|
39
|
+
__exportStar(require("./query-executor/noop-query-executor.js"), exports);
|
|
40
|
+
__exportStar(require("./query-executor/query-executor-provider.js"), exports);
|
|
41
|
+
__exportStar(require("./query-compiler/default-query-compiler.js"), exports);
|
|
42
|
+
__exportStar(require("./query-compiler/compiled-query.js"), exports);
|
|
43
|
+
__exportStar(require("./schema/schema.js"), exports);
|
|
44
|
+
__exportStar(require("./schema/create-table-builder.js"), exports);
|
|
45
|
+
__exportStar(require("./schema/drop-table-builder.js"), exports);
|
|
46
|
+
__exportStar(require("./schema/create-index-builder.js"), exports);
|
|
47
|
+
__exportStar(require("./schema/drop-index-builder.js"), exports);
|
|
48
|
+
__exportStar(require("./schema/create-schema-builder.js"), exports);
|
|
49
|
+
__exportStar(require("./schema/drop-schema-builder.js"), exports);
|
|
50
|
+
__exportStar(require("./schema/column-definition-builder.js"), exports);
|
|
51
|
+
__exportStar(require("./schema/foreign-key-constraint-builder.js"), exports);
|
|
52
|
+
__exportStar(require("./schema/alter-table-builder.js"), exports);
|
|
53
|
+
__exportStar(require("./schema/create-view-builder.js"), exports);
|
|
54
|
+
__exportStar(require("./schema/drop-view-builder.js"), exports);
|
|
55
|
+
__exportStar(require("./dynamic/dynamic.js"), exports);
|
|
56
|
+
__exportStar(require("./driver/driver.js"), exports);
|
|
57
|
+
__exportStar(require("./driver/database-connection.js"), exports);
|
|
58
|
+
__exportStar(require("./driver/connection-provider.js"), exports);
|
|
59
|
+
__exportStar(require("./driver/default-connection-provider.js"), exports);
|
|
60
|
+
__exportStar(require("./driver/single-connection-provider.js"), exports);
|
|
61
|
+
__exportStar(require("./driver/dummy-driver.js"), exports);
|
|
62
|
+
__exportStar(require("./dialect/dialect.js"), exports);
|
|
63
|
+
__exportStar(require("./dialect/dialect-adapter.js"), exports);
|
|
64
|
+
__exportStar(require("./dialect/dialect-adapter-base.js"), exports);
|
|
65
|
+
__exportStar(require("./dialect/database-introspector.js"), exports);
|
|
19
66
|
__exportStar(require("./dialect/sqlite/sqlite-dialect.js"), exports);
|
|
20
67
|
__exportStar(require("./dialect/sqlite/sqlite-dialect-config.js"), exports);
|
|
21
68
|
__exportStar(require("./dialect/sqlite/sqlite-driver.js"), exports);
|
|
69
|
+
__exportStar(require("./dialect/postgres/postgres-query-compiler.js"), exports);
|
|
70
|
+
__exportStar(require("./dialect/postgres/postgres-introspector.js"), exports);
|
|
71
|
+
__exportStar(require("./dialect/postgres/postgres-adapter.js"), exports);
|
|
22
72
|
__exportStar(require("./dialect/mysql/mysql-dialect.js"), exports);
|
|
23
73
|
__exportStar(require("./dialect/mysql/mysql-dialect-config.js"), exports);
|
|
24
74
|
__exportStar(require("./dialect/mysql/mysql-driver.js"), exports);
|
|
75
|
+
__exportStar(require("./dialect/mysql/mysql-query-compiler.js"), exports);
|
|
76
|
+
__exportStar(require("./dialect/mysql/mysql-introspector.js"), exports);
|
|
77
|
+
__exportStar(require("./dialect/mysql/mysql-adapter.js"), exports);
|
|
25
78
|
__exportStar(require("./dialect/postgres/postgres-driver.js"), exports);
|
|
26
79
|
__exportStar(require("./dialect/postgres/postgres-dialect-config.js"), exports);
|
|
27
80
|
__exportStar(require("./dialect/postgres/postgres-dialect.js"), exports);
|
|
81
|
+
__exportStar(require("./dialect/sqlite/sqlite-query-compiler.js"), exports);
|
|
82
|
+
__exportStar(require("./dialect/sqlite/sqlite-introspector.js"), exports);
|
|
83
|
+
__exportStar(require("./dialect/sqlite/sqlite-adapter.js"), exports);
|
|
84
|
+
__exportStar(require("./query-compiler/default-query-compiler.js"), exports);
|
|
85
|
+
__exportStar(require("./query-compiler/query-compiler.js"), exports);
|
|
86
|
+
__exportStar(require("./migration/migrator.js"), exports);
|
|
87
|
+
__exportStar(require("./migration/file-migration-provider.js"), exports);
|
|
88
|
+
__exportStar(require("./plugin/kysely-plugin.js"), exports);
|
|
89
|
+
__exportStar(require("./plugin/camel-case/camel-case-plugin.js"), exports);
|
|
90
|
+
__exportStar(require("./plugin/deduplicate-joins/deduplicate-joins-plugin.js"), exports);
|
|
91
|
+
__exportStar(require("./operation-node/add-column-node.js"), exports);
|
|
92
|
+
__exportStar(require("./operation-node/add-constraint-node.js"), exports);
|
|
93
|
+
__exportStar(require("./operation-node/alias-node.js"), exports);
|
|
94
|
+
__exportStar(require("./operation-node/alter-column-node.js"), exports);
|
|
95
|
+
__exportStar(require("./operation-node/alter-table-node.js"), exports);
|
|
96
|
+
__exportStar(require("./operation-node/and-node.js"), exports);
|
|
97
|
+
__exportStar(require("./operation-node/check-constraint-node.js"), exports);
|
|
98
|
+
__exportStar(require("./operation-node/column-definition-node.js"), exports);
|
|
99
|
+
__exportStar(require("./operation-node/column-node.js"), exports);
|
|
100
|
+
__exportStar(require("./operation-node/column-update-node.js"), exports);
|
|
101
|
+
__exportStar(require("./operation-node/common-table-expression-node.js"), exports);
|
|
102
|
+
__exportStar(require("./operation-node/common-table-expression-name-node.js"), exports);
|
|
103
|
+
__exportStar(require("./operation-node/constraint-node.js"), exports);
|
|
104
|
+
__exportStar(require("./operation-node/create-index-node.js"), exports);
|
|
105
|
+
__exportStar(require("./operation-node/create-schema-node.js"), exports);
|
|
106
|
+
__exportStar(require("./operation-node/create-table-node.js"), exports);
|
|
107
|
+
__exportStar(require("./operation-node/create-view-node.js"), exports);
|
|
108
|
+
__exportStar(require("./operation-node/data-type-node.js"), exports);
|
|
109
|
+
__exportStar(require("./operation-node/default-value-node.js"), exports);
|
|
110
|
+
__exportStar(require("./operation-node/delete-query-node.js"), exports);
|
|
111
|
+
__exportStar(require("./operation-node/drop-column-node.js"), exports);
|
|
112
|
+
__exportStar(require("./operation-node/drop-constraint-node.js"), exports);
|
|
113
|
+
__exportStar(require("./operation-node/drop-index-node.js"), exports);
|
|
114
|
+
__exportStar(require("./operation-node/drop-schema-node.js"), exports);
|
|
115
|
+
__exportStar(require("./operation-node/drop-table-node.js"), exports);
|
|
116
|
+
__exportStar(require("./operation-node/drop-view-node.js"), exports);
|
|
117
|
+
__exportStar(require("./operation-node/filter-node.js"), exports);
|
|
118
|
+
__exportStar(require("./operation-node/foreign-key-constraint-node.js"), exports);
|
|
119
|
+
__exportStar(require("./operation-node/from-node.js"), exports);
|
|
120
|
+
__exportStar(require("./operation-node/generated-node.js"), exports);
|
|
121
|
+
__exportStar(require("./operation-node/group-by-item-node.js"), exports);
|
|
122
|
+
__exportStar(require("./operation-node/group-by-node.js"), exports);
|
|
123
|
+
__exportStar(require("./operation-node/having-node.js"), exports);
|
|
124
|
+
__exportStar(require("./operation-node/identifier-node.js"), exports);
|
|
125
|
+
__exportStar(require("./operation-node/insert-query-node.js"), exports);
|
|
126
|
+
__exportStar(require("./operation-node/join-node.js"), exports);
|
|
127
|
+
__exportStar(require("./operation-node/limit-node.js"), exports);
|
|
128
|
+
__exportStar(require("./operation-node/list-node.js"), exports);
|
|
129
|
+
__exportStar(require("./operation-node/modify-column-node.js"), exports);
|
|
130
|
+
__exportStar(require("./operation-node/offset-node.js"), exports);
|
|
131
|
+
__exportStar(require("./operation-node/on-conflict-node.js"), exports);
|
|
132
|
+
__exportStar(require("./operation-node/on-duplicate-key-node.js"), exports);
|
|
133
|
+
__exportStar(require("./operation-node/on-node.js"), exports);
|
|
134
|
+
__exportStar(require("./operation-node/operation-node-source.js"), exports);
|
|
135
|
+
__exportStar(require("./operation-node/operation-node-transformer.js"), exports);
|
|
136
|
+
__exportStar(require("./operation-node/operation-node-utils.js"), exports);
|
|
137
|
+
__exportStar(require("./operation-node/operation-node-visitor.js"), exports);
|
|
138
|
+
__exportStar(require("./operation-node/operation-node.js"), exports);
|
|
139
|
+
__exportStar(require("./operation-node/operator-node.js"), exports);
|
|
140
|
+
__exportStar(require("./operation-node/or-node.js"), exports);
|
|
141
|
+
__exportStar(require("./operation-node/order-by-item-node.js"), exports);
|
|
142
|
+
__exportStar(require("./operation-node/order-by-node.js"), exports);
|
|
143
|
+
__exportStar(require("./operation-node/parens-node.js"), exports);
|
|
144
|
+
__exportStar(require("./operation-node/primary-constraint-node.js"), exports);
|
|
145
|
+
__exportStar(require("./operation-node/primitive-value-list-node.js"), exports);
|
|
146
|
+
__exportStar(require("./operation-node/query-node.js"), exports);
|
|
147
|
+
__exportStar(require("./operation-node/raw-node.js"), exports);
|
|
148
|
+
__exportStar(require("./operation-node/reference-node.js"), exports);
|
|
149
|
+
__exportStar(require("./operation-node/references-node.js"), exports);
|
|
150
|
+
__exportStar(require("./operation-node/rename-column-node.js"), exports);
|
|
151
|
+
__exportStar(require("./operation-node/returning-node.js"), exports);
|
|
152
|
+
__exportStar(require("./operation-node/select-all-node.js"), exports);
|
|
153
|
+
__exportStar(require("./operation-node/select-query-node.js"), exports);
|
|
154
|
+
__exportStar(require("./operation-node/select-query-node.js"), exports);
|
|
155
|
+
__exportStar(require("./operation-node/selection-node.js"), exports);
|
|
156
|
+
__exportStar(require("./operation-node/table-node.js"), exports);
|
|
157
|
+
__exportStar(require("./operation-node/union-node.js"), exports);
|
|
158
|
+
__exportStar(require("./operation-node/unique-constraint-node.js"), exports);
|
|
159
|
+
__exportStar(require("./operation-node/update-query-node.js"), exports);
|
|
160
|
+
__exportStar(require("./operation-node/value-list-node.js"), exports);
|
|
161
|
+
__exportStar(require("./operation-node/value-node.js"), exports);
|
|
162
|
+
__exportStar(require("./operation-node/values-node.js"), exports);
|
|
163
|
+
__exportStar(require("./operation-node/where-node.js"), exports);
|
|
164
|
+
__exportStar(require("./operation-node/with-node.js"), exports);
|
|
165
|
+
__exportStar(require("./util/column-type.js"), exports);
|
|
166
|
+
__exportStar(require("./util/compilable.js"), exports);
|
|
167
|
+
__exportStar(require("./util/log.js"), exports);
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { Migration, MigrationProvider } from './migrator.js';
|
|
2
2
|
/**
|
|
3
|
-
* Reads all migrations from a folder.
|
|
3
|
+
* Reads all migrations from a folder in node.js.
|
|
4
4
|
*
|
|
5
5
|
* ### Examples
|
|
6
6
|
*
|
|
7
7
|
* ```ts
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* import { promises as fs } from 'fs'
|
|
9
|
+
* import path from 'path'
|
|
10
|
+
*
|
|
11
|
+
* new FileMigrationProvider({
|
|
12
|
+
* fs,
|
|
13
|
+
* path,
|
|
14
|
+
* migrationFolder: 'path/to/migrations/folder'
|
|
15
|
+
* })
|
|
11
16
|
* ```
|
|
12
17
|
*/
|
|
13
18
|
export declare class FileMigrationProvider implements MigrationProvider {
|
|
14
19
|
#private;
|
|
15
|
-
constructor(
|
|
20
|
+
constructor(props: FileMigrationProviderProps);
|
|
16
21
|
/**
|
|
17
22
|
* Returns all migrations, old and new.
|
|
18
23
|
*
|
|
@@ -27,3 +32,14 @@ export declare class FileMigrationProvider implements MigrationProvider {
|
|
|
27
32
|
*/
|
|
28
33
|
getMigrations(): Promise<Record<string, Migration>>;
|
|
29
34
|
}
|
|
35
|
+
export interface FileMigrationProviderFS {
|
|
36
|
+
readdir(path: string): Promise<string[]>;
|
|
37
|
+
}
|
|
38
|
+
export interface FileMigrationProviderPath {
|
|
39
|
+
join(...path: string[]): string;
|
|
40
|
+
}
|
|
41
|
+
export interface FileMigrationProviderProps {
|
|
42
|
+
fs: FileMigrationProviderFS;
|
|
43
|
+
path: FileMigrationProviderPath;
|
|
44
|
+
migrationFolder: string;
|
|
45
|
+
}
|
|
@@ -3,32 +3,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FileMigrationProvider = void 0;
|
|
4
4
|
const object_utils_js_1 = require("../util/object-utils.js");
|
|
5
5
|
/**
|
|
6
|
-
* Reads all migrations from a folder.
|
|
6
|
+
* Reads all migrations from a folder in node.js.
|
|
7
7
|
*
|
|
8
8
|
* ### Examples
|
|
9
9
|
*
|
|
10
10
|
* ```ts
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* import { promises as fs } from 'fs'
|
|
12
|
+
* import path from 'path'
|
|
13
|
+
*
|
|
14
|
+
* new FileMigrationProvider({
|
|
15
|
+
* fs,
|
|
16
|
+
* path,
|
|
17
|
+
* migrationFolder: 'path/to/migrations/folder'
|
|
18
|
+
* })
|
|
14
19
|
* ```
|
|
15
20
|
*/
|
|
16
21
|
class FileMigrationProvider {
|
|
17
|
-
#
|
|
18
|
-
constructor(
|
|
19
|
-
this.#
|
|
22
|
+
#props;
|
|
23
|
+
constructor(props) {
|
|
24
|
+
this.#props = props;
|
|
20
25
|
}
|
|
21
26
|
async getMigrations() {
|
|
22
|
-
// Import these dynamically so that we don't have any top level
|
|
23
|
-
// node dependencies.
|
|
24
|
-
const fs = await Promise.resolve().then(() => require('fs/promises'));
|
|
25
|
-
const path = await Promise.resolve().then(() => require('path'));
|
|
26
27
|
const migrations = {};
|
|
27
|
-
const files = await fs.readdir(this.#
|
|
28
|
+
const files = await this.#props.fs.readdir(this.#props.migrationFolder);
|
|
28
29
|
for (const fileName of files) {
|
|
29
30
|
if ((fileName.endsWith('.js') || fileName.endsWith('.ts')) &&
|
|
30
31
|
!fileName.endsWith('.d.ts')) {
|
|
31
|
-
const migration = await Promise.resolve().then(() => require(path.join(this.#
|
|
32
|
+
const migration = await Promise.resolve().then(() => require(this.#props.path.join(this.#props.migrationFolder, fileName)));
|
|
32
33
|
if (isMigration(migration)) {
|
|
33
34
|
migrations[fileName.substring(0, fileName.length - 3)] = migration;
|
|
34
35
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { QueryResult } from '../driver/database-connection.js';
|
|
2
|
-
import { UnknownRow } from '../index-nodeless.js';
|
|
3
2
|
import { RootOperationNode } from '../query-compiler/query-compiler.js';
|
|
3
|
+
import { UnknownRow } from '../util/type-utils.js';
|
|
4
4
|
import { KyselyPlugin, PluginTransformQueryArgs, PluginTransformResultArgs } from './kysely-plugin.js';
|
|
5
5
|
export declare class NoopPlugin implements KyselyPlugin {
|
|
6
6
|
/**
|
|
@@ -2,223 +2,40 @@ import { DatabaseConnection } from '../../driver/database-connection.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Config for the MySQL dialect.
|
|
4
4
|
*
|
|
5
|
-
* This interface is equal to `mysql2` library's pool config.
|
|
6
|
-
*
|
|
7
5
|
* https://github.com/sidorares/node-mysql2#using-connection-pools
|
|
8
6
|
*/
|
|
9
7
|
export interface MysqlDialectConfig {
|
|
10
8
|
/**
|
|
11
|
-
*
|
|
12
|
-
*/
|
|
13
|
-
user?: string;
|
|
14
|
-
/**
|
|
15
|
-
* The password of that MySQL user
|
|
16
|
-
*/
|
|
17
|
-
password?: string;
|
|
18
|
-
/**
|
|
19
|
-
* Name of the database to use for this connection
|
|
20
|
-
*/
|
|
21
|
-
database?: string;
|
|
22
|
-
/**
|
|
23
|
-
* The charset for the connection. This is called 'collation' in the SQL-level of MySQL (like utf8_general_ci).
|
|
24
|
-
* If a SQL-level charset is specified (like utf8mb4) then the default collation for that charset is used.
|
|
25
|
-
* (Default: 'UTF8_GENERAL_CI')
|
|
26
|
-
*/
|
|
27
|
-
charset?: string;
|
|
28
|
-
/**
|
|
29
|
-
* The hostname of the database you are connecting to. (Default: localhost)
|
|
30
|
-
*/
|
|
31
|
-
host?: string;
|
|
32
|
-
/**
|
|
33
|
-
* The port number to connect to. (Default: 3306)
|
|
34
|
-
*/
|
|
35
|
-
port?: number;
|
|
36
|
-
/**
|
|
37
|
-
* The source IP address to use for TCP connection
|
|
38
|
-
*/
|
|
39
|
-
localAddress?: string;
|
|
40
|
-
/**
|
|
41
|
-
* The path to a unix domain socket to connect to. When used host and port are ignored
|
|
42
|
-
*/
|
|
43
|
-
socketPath?: string;
|
|
44
|
-
/**
|
|
45
|
-
* The timezone used to store local dates. (Default: 'local')
|
|
46
|
-
*/
|
|
47
|
-
timezone?: string | 'local';
|
|
48
|
-
/**
|
|
49
|
-
* The milliseconds before a timeout occurs during the initial connection to the MySQL server. (Default: 10 seconds)
|
|
50
|
-
*/
|
|
51
|
-
connectTimeout?: number;
|
|
52
|
-
/**
|
|
53
|
-
* Stringify objects instead of converting to values. (Default: 'false')
|
|
54
|
-
*/
|
|
55
|
-
stringifyObjects?: boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Allow connecting to MySQL instances that ask for the old (insecure) authentication method. (Default: false)
|
|
58
|
-
*/
|
|
59
|
-
insecureAuth?: boolean;
|
|
60
|
-
/**
|
|
61
|
-
* Determines if column values should be converted to native JavaScript types. It is not recommended (and may go away / change in the future)
|
|
62
|
-
* to disable type casting, but you can currently do so on either the connection or query level. (Default: true)
|
|
63
|
-
*
|
|
64
|
-
* You can also specify a function (field: any, next: () => void) => {} to do the type casting yourself.
|
|
65
|
-
*
|
|
66
|
-
* WARNING: YOU MUST INVOKE the parser using one of these three field functions in your custom typeCast callback. They can only be called once.
|
|
67
|
-
*
|
|
68
|
-
* field.string()
|
|
69
|
-
* field.buffer()
|
|
70
|
-
* field.geometry()
|
|
71
|
-
*
|
|
72
|
-
* are aliases for
|
|
73
|
-
*
|
|
74
|
-
* parser.parseLengthCodedString()
|
|
75
|
-
* parser.parseLengthCodedBuffer()
|
|
76
|
-
* parser.parseGeometryValue()
|
|
77
|
-
*
|
|
78
|
-
* You can find which field function you need to use by looking at: RowDataPacket.prototype._typeCast
|
|
79
|
-
*/
|
|
80
|
-
typeCast?: boolean | ((field: any, next: () => void) => any);
|
|
81
|
-
/**
|
|
82
|
-
* A custom query format function
|
|
83
|
-
*/
|
|
84
|
-
queryFormat?: (query: string, values: any) => void;
|
|
85
|
-
/**
|
|
86
|
-
* When dealing with big numbers (BIGINT and DECIMAL columns) in the database, you should enable this option
|
|
87
|
-
* (Default: false)
|
|
88
|
-
*/
|
|
89
|
-
supportBigNumbers?: boolean;
|
|
90
|
-
/**
|
|
91
|
-
* Enabling both supportBigNumbers and bigNumberStrings forces big numbers (BIGINT and DECIMAL columns) to be
|
|
92
|
-
* always returned as JavaScript String objects (Default: false). Enabling supportBigNumbers but leaving
|
|
93
|
-
* bigNumberStrings disabled will return big numbers as String objects only when they cannot be accurately
|
|
94
|
-
* represented with [JavaScript Number objects] (http://ecma262-5.com/ELS5_HTML.htm#Section_8.5)
|
|
95
|
-
* (which happens when they exceed the [-2^53, +2^53] range), otherwise they will be returned as Number objects.
|
|
96
|
-
* This option is ignored if supportBigNumbers is disabled.
|
|
97
|
-
*/
|
|
98
|
-
bigNumberStrings?: boolean;
|
|
99
|
-
/**
|
|
100
|
-
* Force date types (TIMESTAMP, DATETIME, DATE) to be returned as strings rather then inflated into JavaScript Date
|
|
101
|
-
* objects. Can be true/false or an array of type names to keep as strings.
|
|
9
|
+
* A mysql2 Pool instance or a function that returns one.
|
|
102
10
|
*
|
|
103
|
-
*
|
|
104
|
-
*/
|
|
105
|
-
dateStrings?: boolean | Array<'TIMESTAMP' | 'DATETIME' | 'DATE'>;
|
|
106
|
-
/**
|
|
107
|
-
* This will print all incoming and outgoing packets on stdout.
|
|
108
|
-
* You can also restrict debugging to packet types by passing an array of types (strings) to debug;
|
|
11
|
+
* If a function is provided, it's called once when the first query is executed.
|
|
109
12
|
*
|
|
110
|
-
*
|
|
13
|
+
* https://github.com/sidorares/node-mysql2#using-connection-pools
|
|
111
14
|
*/
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Generates stack traces on Error to include call site of library entrance ('long stack traces'). Slight
|
|
115
|
-
* performance penalty for most calls. (Default: true)
|
|
116
|
-
*/
|
|
117
|
-
trace?: boolean;
|
|
118
|
-
/**
|
|
119
|
-
* Allow multiple MySQL statements per query. Be careful with this, it exposes you to SQL injection attacks. (Default: false)
|
|
120
|
-
*/
|
|
121
|
-
multipleStatements?: boolean;
|
|
122
|
-
/**
|
|
123
|
-
* List of connection flags to use other than the default ones. It is also possible to blacklist default ones
|
|
124
|
-
*/
|
|
125
|
-
flags?: Array<string>;
|
|
126
|
-
/**
|
|
127
|
-
* object with ssl parameters or a string containing name of ssl profile
|
|
128
|
-
*/
|
|
129
|
-
ssl?: string | MysqlSslOptions;
|
|
130
|
-
/**
|
|
131
|
-
* Return each row as an array, not as an object.
|
|
132
|
-
* This is useful when you have duplicate column names.
|
|
133
|
-
* This can also be set in the `QueryOption` object to be applied per-query.
|
|
134
|
-
*/
|
|
135
|
-
rowsAsArray?: boolean;
|
|
136
|
-
/**
|
|
137
|
-
* The milliseconds before a timeout occurs during the connection acquisition. This is slightly different from connectTimeout,
|
|
138
|
-
* because acquiring a pool connection does not always involve making a connection. (Default: 10 seconds)
|
|
139
|
-
*/
|
|
140
|
-
acquireTimeout?: number;
|
|
141
|
-
/**
|
|
142
|
-
* Determines the pool's action when no connections are available and the limit has been reached. If true, the pool will queue
|
|
143
|
-
* the connection request and call it when one becomes available. If false, the pool will immediately call back with an error.
|
|
144
|
-
* (Default: true)
|
|
145
|
-
*/
|
|
146
|
-
waitForConnections?: boolean;
|
|
147
|
-
/**
|
|
148
|
-
* The maximum number of connections to create at once. (Default: 10)
|
|
149
|
-
*/
|
|
150
|
-
connectionLimit?: number;
|
|
151
|
-
/**
|
|
152
|
-
* The maximum number of connection requests the pool will queue before returning an error from getConnection. If set to 0, there
|
|
153
|
-
* is no limit to the number of queued connection requests. (Default: 0)
|
|
154
|
-
*/
|
|
155
|
-
queueLimit?: number;
|
|
156
|
-
/**
|
|
157
|
-
* Enable keep-alive on the socket. It's disabled by default, but the
|
|
158
|
-
* user can enable it and supply an initial delay.
|
|
159
|
-
*/
|
|
160
|
-
enableKeepAlive?: true;
|
|
161
|
-
/**
|
|
162
|
-
* If keep-alive is enabled users can supply an initial delay.
|
|
163
|
-
*/
|
|
164
|
-
keepAliveInitialDelay?: number;
|
|
165
|
-
charsetNumber?: number;
|
|
166
|
-
compress?: boolean;
|
|
167
|
-
authSwitchHandler?: (data: any, callback: () => void) => any;
|
|
168
|
-
connectAttributes?: {
|
|
169
|
-
[param: string]: any;
|
|
170
|
-
};
|
|
171
|
-
decimalNumbers?: boolean;
|
|
172
|
-
isServer?: boolean;
|
|
173
|
-
maxPreparedStatements?: number;
|
|
174
|
-
namedPlaceholders?: boolean;
|
|
175
|
-
nestTables?: boolean | string;
|
|
176
|
-
passwordSha1?: string;
|
|
177
|
-
pool?: any;
|
|
178
|
-
stream?: any;
|
|
179
|
-
uri?: string;
|
|
180
|
-
Promise?: any;
|
|
181
|
-
authPlugins?: {
|
|
182
|
-
[key: string]: any;
|
|
183
|
-
};
|
|
15
|
+
pool: MysqlPool | (() => Promise<MysqlPool>);
|
|
184
16
|
/**
|
|
185
17
|
* Called once for each created connection.
|
|
186
|
-
*
|
|
187
|
-
* This is a Kysely specific feature and does not come from the `mysql2` module.
|
|
188
18
|
*/
|
|
189
19
|
onCreateConnection?: (connection: DatabaseConnection) => Promise<void>;
|
|
190
20
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
*/
|
|
211
|
-
ca?: string | string[];
|
|
212
|
-
/**
|
|
213
|
-
* Either a string or list of strings of PEM encoded CRLs (Certificate Revocation List)
|
|
214
|
-
*/
|
|
215
|
-
crl?: string | string[];
|
|
216
|
-
/**
|
|
217
|
-
* A string describing the ciphers to use or exclude
|
|
218
|
-
*/
|
|
219
|
-
ciphers?: string;
|
|
220
|
-
/**
|
|
221
|
-
* You can also connect to a MySQL server without properly providing the appropriate CA to trust. You should not do this.
|
|
222
|
-
*/
|
|
223
|
-
rejectUnauthorized?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* This interface is the subset of mysql2 driver's `Pool` class that
|
|
23
|
+
* kysely needs.
|
|
24
|
+
*
|
|
25
|
+
* We don't use the type from `mysql2` here to not have a dependency to it.
|
|
26
|
+
*
|
|
27
|
+
* https://github.com/sidorares/node-mysql2#using-connection-pools
|
|
28
|
+
*/
|
|
29
|
+
export interface MysqlPool {
|
|
30
|
+
getConnection(callback: (error: unknown, connection: MysqlPoolConnection) => void): void;
|
|
31
|
+
end(callback: (error: unknown) => void): void;
|
|
32
|
+
}
|
|
33
|
+
export interface MysqlPoolConnection {
|
|
34
|
+
query(sql: string, parameters: ReadonlyArray<unknown>, callback: (error: unknown, result: MysqlQueryResult) => void): void;
|
|
35
|
+
release(): void;
|
|
36
|
+
}
|
|
37
|
+
export interface MysqlOkPacket {
|
|
38
|
+
affectedRows: number;
|
|
39
|
+
insertId: number;
|
|
224
40
|
}
|
|
41
|
+
export declare type MysqlQueryResult = MysqlOkPacket | Record<string, unknown>[];
|
|
@@ -3,26 +3,41 @@ import { Kysely } from '../../kysely.js';
|
|
|
3
3
|
import { QueryCompiler } from '../../query-compiler/query-compiler.js';
|
|
4
4
|
import { Dialect } from '../dialect.js';
|
|
5
5
|
import { DatabaseIntrospector } from '../database-introspector.js';
|
|
6
|
-
import { MysqlPool } from './mysql-driver.js';
|
|
7
6
|
import { DialectAdapter } from '../dialect-adapter.js';
|
|
8
7
|
import { MysqlDialectConfig } from './mysql-dialect-config.js';
|
|
9
8
|
/**
|
|
10
9
|
* MySQL dialect that uses the [mysql2](https://github.com/sidorares/node-mysql2#readme) library.
|
|
11
10
|
*
|
|
12
|
-
* The {@link MysqlDialectConfig
|
|
13
|
-
* is given as-is to the mysql2 library's [createPool](https://github.com/sidorares/node-mysql2#using-connection-pools)
|
|
14
|
-
* method.
|
|
11
|
+
* The constructor takes an instance of {@link MysqlDialectConfig}.
|
|
15
12
|
*
|
|
16
|
-
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { createPool } from 'mysql2'
|
|
15
|
+
*
|
|
16
|
+
* new MysqlDialect({
|
|
17
|
+
* pool: createPool({
|
|
18
|
+
* database: 'some_db',
|
|
19
|
+
* host: 'localhost',
|
|
20
|
+
* })
|
|
21
|
+
* })
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* If you want the pool to only be created once it's first used, `pool`
|
|
25
|
+
* can be a function:
|
|
17
26
|
*
|
|
18
27
|
* ```ts
|
|
19
28
|
* import { createPool } from 'mysql2'
|
|
20
|
-
*
|
|
29
|
+
*
|
|
30
|
+
* new MysqlDialect({
|
|
31
|
+
* pool: async () => createPool({
|
|
32
|
+
* database: 'some_db',
|
|
33
|
+
* host: 'localhost',
|
|
34
|
+
* })
|
|
35
|
+
* })
|
|
21
36
|
* ```
|
|
22
37
|
*/
|
|
23
38
|
export declare class MysqlDialect implements Dialect {
|
|
24
39
|
#private;
|
|
25
|
-
constructor(
|
|
40
|
+
constructor(config: MysqlDialectConfig);
|
|
26
41
|
/**
|
|
27
42
|
* Creates a driver for the dialect.
|
|
28
43
|
*/
|
|
@@ -6,24 +6,40 @@ import { MysqlAdapter } from './mysql-adapter.js';
|
|
|
6
6
|
/**
|
|
7
7
|
* MySQL dialect that uses the [mysql2](https://github.com/sidorares/node-mysql2#readme) library.
|
|
8
8
|
*
|
|
9
|
-
* The {@link MysqlDialectConfig
|
|
10
|
-
* is given as-is to the mysql2 library's [createPool](https://github.com/sidorares/node-mysql2#using-connection-pools)
|
|
11
|
-
* method.
|
|
9
|
+
* The constructor takes an instance of {@link MysqlDialectConfig}.
|
|
12
10
|
*
|
|
13
|
-
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { createPool } from 'mysql2'
|
|
13
|
+
*
|
|
14
|
+
* new MysqlDialect({
|
|
15
|
+
* pool: createPool({
|
|
16
|
+
* database: 'some_db',
|
|
17
|
+
* host: 'localhost',
|
|
18
|
+
* })
|
|
19
|
+
* })
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* If you want the pool to only be created once it's first used, `pool`
|
|
23
|
+
* can be a function:
|
|
14
24
|
*
|
|
15
25
|
* ```ts
|
|
16
26
|
* import { createPool } from 'mysql2'
|
|
17
|
-
*
|
|
27
|
+
*
|
|
28
|
+
* new MysqlDialect({
|
|
29
|
+
* pool: async () => createPool({
|
|
30
|
+
* database: 'some_db',
|
|
31
|
+
* host: 'localhost',
|
|
32
|
+
* })
|
|
33
|
+
* })
|
|
18
34
|
* ```
|
|
19
35
|
*/
|
|
20
36
|
export class MysqlDialect {
|
|
21
|
-
#
|
|
22
|
-
constructor(
|
|
23
|
-
this.#
|
|
37
|
+
#config;
|
|
38
|
+
constructor(config) {
|
|
39
|
+
this.#config = config;
|
|
24
40
|
}
|
|
25
41
|
createDriver() {
|
|
26
|
-
return new MysqlDriver(this.#
|
|
42
|
+
return new MysqlDriver(this.#config);
|
|
27
43
|
}
|
|
28
44
|
createQueryCompiler() {
|
|
29
45
|
return new MysqlQueryCompiler();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { DatabaseConnection, QueryResult } from '../../driver/database-connection.js';
|
|
2
2
|
import { Driver, TransactionSettings } from '../../driver/driver.js';
|
|
3
3
|
import { CompiledQuery } from '../../query-compiler/compiled-query.js';
|
|
4
|
-
import { MysqlDialectConfig } from './mysql-dialect-config.js';
|
|
4
|
+
import { MysqlDialectConfig, MysqlPoolConnection } from './mysql-dialect-config.js';
|
|
5
5
|
declare const PRIVATE_RELEASE_METHOD: unique symbol;
|
|
6
6
|
export declare class MysqlDriver implements Driver {
|
|
7
7
|
#private;
|
|
8
|
-
constructor(configOrPool: MysqlDialectConfig
|
|
8
|
+
constructor(configOrPool: MysqlDialectConfig);
|
|
9
9
|
/**
|
|
10
10
|
* Initializes the driver.
|
|
11
11
|
*
|
|
@@ -43,19 +43,6 @@ export declare class MysqlDriver implements Driver {
|
|
|
43
43
|
*/
|
|
44
44
|
destroy(): Promise<void>;
|
|
45
45
|
}
|
|
46
|
-
export interface MysqlPool {
|
|
47
|
-
getConnection(callback: (error: unknown, connection: MysqlPoolConnection) => void): void;
|
|
48
|
-
end(callback: (error: unknown) => void): void;
|
|
49
|
-
}
|
|
50
|
-
interface MysqlPoolConnection {
|
|
51
|
-
query(sql: string, parameters: ReadonlyArray<unknown>, callback: (error: unknown, result: MysqlQueryResult) => void): void;
|
|
52
|
-
release(): void;
|
|
53
|
-
}
|
|
54
|
-
interface MysqlOkPacket {
|
|
55
|
-
affectedRows: number;
|
|
56
|
-
insertId: number;
|
|
57
|
-
}
|
|
58
|
-
declare type MysqlQueryResult = MysqlOkPacket | Record<string, unknown>[];
|
|
59
46
|
declare class MysqlConnection implements DatabaseConnection {
|
|
60
47
|
#private;
|
|
61
48
|
constructor(rawConnection: MysqlPoolConnection);
|