@bdkinc/knex-ibmi 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.js +21 -18
- package/package.json +1 -1
- package/src/execution/ibmi-transaction.ts +3 -3
- package/src/index.ts +34 -27
- package/src/knex-shim.d.ts +283 -0
- package/src/query/ibmi-querycompiler.ts +0 -1
package/README.md
CHANGED
|
@@ -105,6 +105,7 @@ try {
|
|
|
105
105
|
```
|
|
106
106
|
|
|
107
107
|
or as Typescript
|
|
108
|
+
note: you will probably need to add skipLibCheck: true in your tsconfig compilerOptions if not there already. I plan to clean up the types so this is not an issue.
|
|
108
109
|
|
|
109
110
|
```typescript
|
|
110
111
|
import { knex } from "knex";
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import QueryCompiler from 'knex/lib/query/querycompiler';
|
|
|
8
8
|
|
|
9
9
|
declare class IBMiSchemaCompiler extends SchemaCompiler {
|
|
10
10
|
hasTable(tableName: any): void;
|
|
11
|
-
toSQL(): any;
|
|
11
|
+
toSQL(): any[];
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
declare class IBMiTableCompiler extends TableCompiler {
|
|
@@ -42,12 +42,14 @@ declare class IBMiQueryCompiler extends QueryCompiler {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
declare class DB2Client extends knex.Client {
|
|
45
|
-
constructor(config:
|
|
45
|
+
constructor(config: Knex.Config<DB2Config>);
|
|
46
46
|
_driver(): typeof odbc;
|
|
47
47
|
printDebug(message: string): void;
|
|
48
|
+
printError(message: string): void;
|
|
49
|
+
printWarn(message: string): void;
|
|
48
50
|
acquireRawConnection(): Promise<any>;
|
|
49
51
|
destroyRawConnection(connection: Connection): Promise<void>;
|
|
50
|
-
_getConnectionString(connectionConfig:
|
|
52
|
+
_getConnectionString(connectionConfig: DB2ConnectionConfig): string;
|
|
51
53
|
_query(connection: any, obj: any): Promise<any>;
|
|
52
54
|
transaction(container: any, config: any, outerTx: any): Knex.Transaction;
|
|
53
55
|
schemaCompiler(): IBMiSchemaCompiler;
|
|
@@ -75,7 +77,7 @@ interface DB2ConnectionParams {
|
|
|
75
77
|
DECFLOATERROROPTION?: 0 | 1;
|
|
76
78
|
DECFLOATROUNDMODE?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
77
79
|
MAPDECIMALFLOATDESCRIBE?: 1 | 3;
|
|
78
|
-
ALLOWPROCCALLS
|
|
80
|
+
ALLOWPROCCALLS?: 0 | 1;
|
|
79
81
|
}
|
|
80
82
|
interface DB2ConnectionConfig {
|
|
81
83
|
database: string;
|
package/dist/index.js
CHANGED
|
@@ -350,7 +350,7 @@ var DB2Client = class extends import_knex.knex.Client {
|
|
|
350
350
|
super(config);
|
|
351
351
|
this.driverName = "odbc";
|
|
352
352
|
if (this.dialect && !this.config.client) {
|
|
353
|
-
this.
|
|
353
|
+
this.printWarn(
|
|
354
354
|
`Using 'this.dialect' to identify the client is deprecated and support for it will be removed in the future. Please use configuration option 'client' instead.`
|
|
355
355
|
);
|
|
356
356
|
}
|
|
@@ -382,22 +382,31 @@ var DB2Client = class extends import_knex.knex.Client {
|
|
|
382
382
|
this.logger.debug("knex-ibmi: " + message);
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
|
+
printError(message) {
|
|
386
|
+
if (process.env.DEBUG === "true") {
|
|
387
|
+
this.logger.error("knex-ibmi: " + message);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
printWarn(message) {
|
|
391
|
+
if (process.env.DEBUG === "true") {
|
|
392
|
+
this.logger.warn("knex-ibmi: " + message);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
385
395
|
// Get a raw connection, called by the pool manager whenever a new
|
|
386
396
|
// connection needs to be added to the pool.
|
|
387
397
|
async acquireRawConnection() {
|
|
388
398
|
this.printDebug("acquiring raw connection");
|
|
389
399
|
const connectionConfig = this.config.connection;
|
|
390
|
-
this.printDebug(
|
|
400
|
+
this.printDebug(
|
|
401
|
+
// @ts-ignore
|
|
402
|
+
"connection config: " + this._getConnectionString(connectionConfig)
|
|
403
|
+
);
|
|
391
404
|
if (this.config?.pool) {
|
|
392
405
|
const poolConfig = {
|
|
393
|
-
connectionString: this._getConnectionString(connectionConfig),
|
|
394
|
-
connectionTimeout: (
|
|
395
|
-
// @ts-ignore
|
|
396
|
-
this.config?.acquireConnectionTimeout || 6e4
|
|
397
|
-
),
|
|
398
406
|
// @ts-ignore
|
|
407
|
+
connectionString: this._getConnectionString(connectionConfig),
|
|
408
|
+
connectionTimeout: this.config?.acquireConnectionTimeout || 6e4,
|
|
399
409
|
initialSize: this.config?.pool?.min || 2,
|
|
400
|
-
// @ts-ignore
|
|
401
410
|
maxSize: this.config?.pool?.max || 10,
|
|
402
411
|
reuseConnection: true
|
|
403
412
|
};
|
|
@@ -405,6 +414,7 @@ var DB2Client = class extends import_knex.knex.Client {
|
|
|
405
414
|
return await pool.connect();
|
|
406
415
|
}
|
|
407
416
|
return await this.driver.connect(
|
|
417
|
+
// @ts-ignore
|
|
408
418
|
this._getConnectionString(connectionConfig)
|
|
409
419
|
);
|
|
410
420
|
}
|
|
@@ -425,7 +435,6 @@ var DB2Client = class extends import_knex.knex.Client {
|
|
|
425
435
|
return `${`DRIVER=${connectionConfig.driver};SYSTEM=${connectionConfig.host};HOSTNAME=${connectionConfig.host};PORT=${connectionConfig.port};DATABASE=${connectionConfig.database};UID=${connectionConfig.user};PWD=${connectionConfig.password};`}${connectionStringExtension}`;
|
|
426
436
|
}
|
|
427
437
|
// Runs the query on the specified connection, providing the bindings
|
|
428
|
-
// and any other necessary prep work.
|
|
429
438
|
async _query(connection, obj) {
|
|
430
439
|
if (!obj || typeof obj == "string")
|
|
431
440
|
obj = { sql: obj };
|
|
@@ -437,8 +446,6 @@ var DB2Client = class extends import_knex.knex.Client {
|
|
|
437
446
|
obj.response = { rows, rowCount: rows.length };
|
|
438
447
|
}
|
|
439
448
|
} else {
|
|
440
|
-
await connection.beginTransaction();
|
|
441
|
-
this.printDebug("transaction begun");
|
|
442
449
|
try {
|
|
443
450
|
const statement = await connection.createStatement();
|
|
444
451
|
await statement.prepare(obj.sql);
|
|
@@ -446,6 +453,7 @@ var DB2Client = class extends import_knex.knex.Client {
|
|
|
446
453
|
await statement.bind(obj.bindings);
|
|
447
454
|
}
|
|
448
455
|
const result = await statement.execute();
|
|
456
|
+
this.printDebug(result);
|
|
449
457
|
if (result.statement.includes("IDENTITY_VAL_LOCAL()")) {
|
|
450
458
|
obj.response = {
|
|
451
459
|
rows: result.map(
|
|
@@ -470,15 +478,10 @@ var DB2Client = class extends import_knex.knex.Client {
|
|
|
470
478
|
obj.response = { rows: result, rowCount: result.count };
|
|
471
479
|
}
|
|
472
480
|
} catch (err) {
|
|
473
|
-
this.
|
|
474
|
-
await connection.rollback();
|
|
475
|
-
throw new Error(err);
|
|
476
|
-
} finally {
|
|
477
|
-
this.printDebug("transaction committed");
|
|
478
|
-
await connection.commit();
|
|
481
|
+
this.printError(err);
|
|
479
482
|
}
|
|
480
483
|
}
|
|
481
|
-
this.printDebug(obj
|
|
484
|
+
this.printDebug(obj);
|
|
482
485
|
return obj;
|
|
483
486
|
}
|
|
484
487
|
transaction(container, config, outerTx) {
|
package/package.json
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
import Transaction from "knex/lib/execution/transaction";
|
|
3
3
|
|
|
4
4
|
class IBMiTransaction extends Transaction {
|
|
5
|
-
async begin(connection) {
|
|
5
|
+
async begin(connection: any) {
|
|
6
6
|
await connection.beginTransaction();
|
|
7
7
|
return connection;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
async rollback(connection) {
|
|
10
|
+
async rollback(connection: any) {
|
|
11
11
|
await connection.rollback();
|
|
12
12
|
return connection;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
async commit(connection) {
|
|
15
|
+
async commit(connection: any) {
|
|
16
16
|
await connection.commit();
|
|
17
17
|
return connection;
|
|
18
18
|
}
|
package/src/index.ts
CHANGED
|
@@ -9,13 +9,12 @@ import Transaction from "./execution/ibmi-transaction";
|
|
|
9
9
|
import QueryCompiler from "./query/ibmi-querycompiler";
|
|
10
10
|
|
|
11
11
|
class DB2Client extends knex.Client {
|
|
12
|
-
constructor(config) {
|
|
12
|
+
constructor(config: Knex.Config<DB2Config>) {
|
|
13
13
|
super(config);
|
|
14
14
|
this.driverName = "odbc";
|
|
15
15
|
|
|
16
16
|
if (this.dialect && !this.config.client) {
|
|
17
|
-
|
|
18
|
-
this.logger.warn(
|
|
17
|
+
this.printWarn(
|
|
19
18
|
`Using 'this.dialect' to identify the client is deprecated and support for it will be removed in the future. Please use configuration option 'client' instead.`,
|
|
20
19
|
);
|
|
21
20
|
}
|
|
@@ -54,23 +53,38 @@ class DB2Client extends knex.Client {
|
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
55
|
|
|
56
|
+
printError(message: string) {
|
|
57
|
+
if (process.env.DEBUG === "true") {
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
this.logger.error("knex-ibmi: " + message);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
printWarn(message: string) {
|
|
64
|
+
if (process.env.DEBUG === "true") {
|
|
65
|
+
// @ts-ignore
|
|
66
|
+
this.logger.warn("knex-ibmi: " + message);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
57
70
|
// Get a raw connection, called by the pool manager whenever a new
|
|
58
71
|
// connection needs to be added to the pool.
|
|
59
72
|
async acquireRawConnection() {
|
|
60
73
|
this.printDebug("acquiring raw connection");
|
|
61
74
|
const connectionConfig = this.config.connection;
|
|
62
|
-
this.printDebug(this._getConnectionString(connectionConfig));
|
|
63
75
|
|
|
64
|
-
|
|
76
|
+
this.printDebug(
|
|
77
|
+
// @ts-ignore
|
|
78
|
+
"connection config: " + this._getConnectionString(connectionConfig),
|
|
79
|
+
);
|
|
80
|
+
|
|
65
81
|
if (this.config?.pool) {
|
|
82
|
+
// @ts-ignore
|
|
66
83
|
const poolConfig = {
|
|
67
|
-
connectionString: this._getConnectionString(connectionConfig),
|
|
68
|
-
connectionTimeout:
|
|
69
|
-
// @ts-ignore
|
|
70
|
-
this.config?.acquireConnectionTimeout || 60000,
|
|
71
84
|
// @ts-ignore
|
|
85
|
+
connectionString: this._getConnectionString(connectionConfig),
|
|
86
|
+
connectionTimeout: this.config?.acquireConnectionTimeout || 60000,
|
|
72
87
|
initialSize: this.config?.pool?.min || 2,
|
|
73
|
-
// @ts-ignore
|
|
74
88
|
maxSize: this.config?.pool?.max || 10,
|
|
75
89
|
reuseConnection: true,
|
|
76
90
|
};
|
|
@@ -79,6 +93,7 @@ class DB2Client extends knex.Client {
|
|
|
79
93
|
}
|
|
80
94
|
|
|
81
95
|
return await this.driver.connect(
|
|
96
|
+
// @ts-ignore
|
|
82
97
|
this._getConnectionString(connectionConfig),
|
|
83
98
|
);
|
|
84
99
|
}
|
|
@@ -90,7 +105,7 @@ class DB2Client extends knex.Client {
|
|
|
90
105
|
return await connection.close();
|
|
91
106
|
}
|
|
92
107
|
|
|
93
|
-
_getConnectionString(connectionConfig) {
|
|
108
|
+
_getConnectionString(connectionConfig: DB2ConnectionConfig) {
|
|
94
109
|
const connectionStringParams =
|
|
95
110
|
connectionConfig.connectionStringParams || {};
|
|
96
111
|
const connectionStringExtension = Object.keys(
|
|
@@ -108,7 +123,6 @@ class DB2Client extends knex.Client {
|
|
|
108
123
|
}
|
|
109
124
|
|
|
110
125
|
// Runs the query on the specified connection, providing the bindings
|
|
111
|
-
// and any other necessary prep work.
|
|
112
126
|
async _query(connection: any, obj: any) {
|
|
113
127
|
if (!obj || typeof obj == "string") obj = { sql: obj };
|
|
114
128
|
const method = (
|
|
@@ -118,32 +132,29 @@ class DB2Client extends knex.Client {
|
|
|
118
132
|
).toLowerCase();
|
|
119
133
|
obj.sqlMethod = method;
|
|
120
134
|
|
|
121
|
-
// Different functions are used since query() doesn't return # of rows affected,
|
|
122
|
-
// which is needed for queries that modify the database
|
|
123
|
-
|
|
124
135
|
if (method === "select" || method === "first" || method === "pluck") {
|
|
125
136
|
const rows: any = await connection.query(obj.sql, obj.bindings);
|
|
126
137
|
if (rows) {
|
|
127
138
|
obj.response = { rows, rowCount: rows.length };
|
|
128
139
|
}
|
|
129
140
|
} else {
|
|
130
|
-
await connection.beginTransaction();
|
|
131
|
-
this.printDebug("transaction begun");
|
|
132
141
|
try {
|
|
133
142
|
const statement = await connection.createStatement();
|
|
134
143
|
await statement.prepare(obj.sql);
|
|
144
|
+
|
|
135
145
|
if (obj.bindings) {
|
|
136
146
|
await statement.bind(obj.bindings);
|
|
137
147
|
}
|
|
148
|
+
|
|
138
149
|
const result = await statement.execute();
|
|
150
|
+
this.printDebug(result);
|
|
139
151
|
// this is hacky we check the SQL for the ID column
|
|
140
|
-
// most dialects return the ID of the inserted
|
|
141
152
|
// we check for the IDENTITY scalar function
|
|
142
153
|
// if that function is present, then we just return the value of the
|
|
143
154
|
// IDENTITY column
|
|
144
155
|
if (result.statement.includes("IDENTITY_VAL_LOCAL()")) {
|
|
145
156
|
obj.response = {
|
|
146
|
-
rows: result.map((row) =>
|
|
157
|
+
rows: result.map((row: { [x: string]: any; }) =>
|
|
147
158
|
result.columns && result.columns?.length > 0
|
|
148
159
|
? row[result.columns[0].name]
|
|
149
160
|
: row,
|
|
@@ -167,16 +178,12 @@ class DB2Client extends knex.Client {
|
|
|
167
178
|
obj.response = { rows: result, rowCount: result.count };
|
|
168
179
|
}
|
|
169
180
|
} catch (err: any) {
|
|
170
|
-
this.
|
|
171
|
-
await connection.rollback();
|
|
172
|
-
throw new Error(err);
|
|
173
|
-
} finally {
|
|
174
|
-
this.printDebug("transaction committed");
|
|
175
|
-
await connection.commit();
|
|
181
|
+
this.printError(err);
|
|
176
182
|
}
|
|
177
183
|
}
|
|
178
184
|
|
|
179
|
-
this.printDebug(obj
|
|
185
|
+
this.printDebug(obj);
|
|
186
|
+
|
|
180
187
|
return obj;
|
|
181
188
|
}
|
|
182
189
|
|
|
@@ -258,7 +265,7 @@ interface DB2ConnectionParams {
|
|
|
258
265
|
DECFLOATERROROPTION?: 0 | 1;
|
|
259
266
|
DECFLOATROUNDMODE?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
260
267
|
MAPDECIMALFLOATDESCRIBE?: 1 | 3;
|
|
261
|
-
ALLOWPROCCALLS
|
|
268
|
+
ALLOWPROCCALLS?: 0 | 1;
|
|
262
269
|
}
|
|
263
270
|
|
|
264
271
|
interface DB2ConnectionConfig {
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
declare module "knex/lib/execution/transaction" {
|
|
2
|
+
import { EventEmitter } from "node:events";
|
|
3
|
+
import { Knex } from "knex";
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
6
|
+
interface Transaction extends Knex.Transaction {}
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
8
|
+
class Transaction extends EventEmitter {
|
|
9
|
+
constructor(client: Knex.Client, container: any, config: any, outerTx: any);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default Transaction;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare module "knex/lib/query/querycompiler" {
|
|
16
|
+
// eslint-disable-next-line no-duplicate-imports
|
|
17
|
+
import { Knex } from "knex";
|
|
18
|
+
|
|
19
|
+
class QueryCompiler {
|
|
20
|
+
client: Knex.Client;
|
|
21
|
+
method: string;
|
|
22
|
+
options: any;
|
|
23
|
+
single: any;
|
|
24
|
+
queryComments: any[];
|
|
25
|
+
timeout: boolean;
|
|
26
|
+
cancelOnTimeout: boolean;
|
|
27
|
+
grouped: any;
|
|
28
|
+
formatter: any;
|
|
29
|
+
_emptyInsertValue: string;
|
|
30
|
+
first: () => any;
|
|
31
|
+
bindings: any[];
|
|
32
|
+
bindingsHolder: this;
|
|
33
|
+
builder: any;
|
|
34
|
+
tableName: string;
|
|
35
|
+
|
|
36
|
+
constructor(
|
|
37
|
+
client: Knex.Client,
|
|
38
|
+
builder: Knex.QueryBuilder,
|
|
39
|
+
bindings?: any,
|
|
40
|
+
);
|
|
41
|
+
toSQL(
|
|
42
|
+
method,
|
|
43
|
+
tz,
|
|
44
|
+
): {
|
|
45
|
+
method: string;
|
|
46
|
+
options: any;
|
|
47
|
+
timeout: boolean;
|
|
48
|
+
cancelOnTimeout: boolean;
|
|
49
|
+
bindings: any[];
|
|
50
|
+
__knexQueryUid: string;
|
|
51
|
+
toNative: () => { sql: string; bindings: any[] };
|
|
52
|
+
sql?: string;
|
|
53
|
+
as?: string;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
select(): string;
|
|
57
|
+
insert(): string | { sql: string; returning?: any };
|
|
58
|
+
with(): string;
|
|
59
|
+
comments(): string;
|
|
60
|
+
columns(): string;
|
|
61
|
+
join(): string;
|
|
62
|
+
where(): string;
|
|
63
|
+
union(): string;
|
|
64
|
+
group(): string;
|
|
65
|
+
having(): string;
|
|
66
|
+
order(): string;
|
|
67
|
+
limit(): string;
|
|
68
|
+
offset(): string;
|
|
69
|
+
lock(): string;
|
|
70
|
+
waitMode(): string;
|
|
71
|
+
wrap(str: string): string;
|
|
72
|
+
|
|
73
|
+
// Internal methods
|
|
74
|
+
_buildInsertValues(insertData: any): string;
|
|
75
|
+
_prepUpdate(data: any): any;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export default QueryCompiler;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
declare module "knex/lib/schema/tablecompiler" {
|
|
82
|
+
// Eslint gets dumb about this
|
|
83
|
+
// eslint-disable-next-line no-duplicate-imports
|
|
84
|
+
import { Knex } from "knex";
|
|
85
|
+
|
|
86
|
+
class TableCompiler {
|
|
87
|
+
constructor(client: Knex.Client, tableBuilder?: Knex.TableBuilder);
|
|
88
|
+
|
|
89
|
+
client: Knex.Client;
|
|
90
|
+
tableBuilder: Knex.TableBuilder;
|
|
91
|
+
_commonBuilder: Knex.TableBuilder;
|
|
92
|
+
method: string;
|
|
93
|
+
schemaNameRaw: string;
|
|
94
|
+
tableNameRaw: string;
|
|
95
|
+
tableNameLikeRaw: string;
|
|
96
|
+
single: any;
|
|
97
|
+
grouped: any;
|
|
98
|
+
formatter: any;
|
|
99
|
+
bindings: any[];
|
|
100
|
+
bindingsHolder: this;
|
|
101
|
+
sequence: any[];
|
|
102
|
+
_formatting: boolean;
|
|
103
|
+
checksCount: number;
|
|
104
|
+
|
|
105
|
+
toSQL(): any[];
|
|
106
|
+
create(ifNot: boolean, like: boolean): void;
|
|
107
|
+
createIfNot(): void;
|
|
108
|
+
createLike(): void;
|
|
109
|
+
createLikeIfNot(): void;
|
|
110
|
+
alter(): void;
|
|
111
|
+
foreign(foreignData: any): void;
|
|
112
|
+
getColumnTypes(columns: any[]): any;
|
|
113
|
+
columnQueries(columns: any[]): void;
|
|
114
|
+
addColumns(columns: any[], prefix?: string): void;
|
|
115
|
+
alterColumns(columns: any[], colBuilders: any[]): void;
|
|
116
|
+
getColumns(method?: string): any[];
|
|
117
|
+
tableName(): string;
|
|
118
|
+
tableNameLike(): string;
|
|
119
|
+
alterTable(): void;
|
|
120
|
+
alterTableForCreate(columnTypes: any): void;
|
|
121
|
+
dropIndex(value: string): void;
|
|
122
|
+
dropUnique(columns: string | string[], indexName: string): void;
|
|
123
|
+
dropForeign(): void;
|
|
124
|
+
dropColumn(): void;
|
|
125
|
+
_setNullableState(column: string, nullable: boolean): void;
|
|
126
|
+
setNullable(column: string): void;
|
|
127
|
+
dropNullable(column: string): void;
|
|
128
|
+
dropChecks(checkConstraintNames: string[]): void;
|
|
129
|
+
check(
|
|
130
|
+
checkPredicate: string,
|
|
131
|
+
bindings: any[],
|
|
132
|
+
constraintName: string,
|
|
133
|
+
): void;
|
|
134
|
+
_addChecks(): string;
|
|
135
|
+
_indexCommand(type: string, tableName: string, columns: string[]): string;
|
|
136
|
+
_getPrimaryKeys(): any[];
|
|
137
|
+
_canBeAddPrimaryKey(options: any): boolean;
|
|
138
|
+
_getIncrementsColumnNames(): any[];
|
|
139
|
+
_getBigIncrementsColumnNames(): any[];
|
|
140
|
+
|
|
141
|
+
pushQuery(query: string | { sql: string; bindings: any }): void;
|
|
142
|
+
pushAdditional(fn: any): void;
|
|
143
|
+
unshiftQuery(query: string | { sql: string; bindings: any }): void;
|
|
144
|
+
|
|
145
|
+
lowerCase: boolean;
|
|
146
|
+
createAlterTableMethods: any;
|
|
147
|
+
addColumnsPrefix: string;
|
|
148
|
+
alterColumnsPrefix: string;
|
|
149
|
+
modifyColumnPrefix: string;
|
|
150
|
+
dropColumnPrefix: string;
|
|
151
|
+
|
|
152
|
+
comment(val: any): void;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export default TableCompiler;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
declare module "knex/lib/schema/columncompiler" {
|
|
159
|
+
// Eslint gets dumb about this
|
|
160
|
+
// eslint-disable-next-line no-duplicate-imports
|
|
161
|
+
import { Knex } from "knex";
|
|
162
|
+
import TableCompiler from "knex/lib/schema/tablecompiler";
|
|
163
|
+
|
|
164
|
+
class ColumnCompiler {
|
|
165
|
+
constructor(
|
|
166
|
+
client: Knex.Client,
|
|
167
|
+
tableCompiler?: TableCompiler,
|
|
168
|
+
columnBuilder?: Knex.ColumnBuilder,
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
client: Knex.Client;
|
|
172
|
+
tableCompiler: TableCompiler;
|
|
173
|
+
columnBuilder: Knex.ColumnBuilder;
|
|
174
|
+
_commonBuilder: Knex.ColumnBuilder;
|
|
175
|
+
args: any[];
|
|
176
|
+
type: string;
|
|
177
|
+
grouped: any;
|
|
178
|
+
modified: any;
|
|
179
|
+
isIncrements: boolean;
|
|
180
|
+
formatter: any;
|
|
181
|
+
bindings: any[];
|
|
182
|
+
bindingsHolder: this;
|
|
183
|
+
sequence: any[];
|
|
184
|
+
modifiers: string[];
|
|
185
|
+
checksCount: number;
|
|
186
|
+
_columnType: string;
|
|
187
|
+
|
|
188
|
+
_addCheckModifiers(): void;
|
|
189
|
+
defaults(label: string): any;
|
|
190
|
+
toSQL(): any[];
|
|
191
|
+
compileColumn(): string;
|
|
192
|
+
getColumnName(): string;
|
|
193
|
+
getColumnType(): string;
|
|
194
|
+
getModifiers(): string;
|
|
195
|
+
|
|
196
|
+
varchar(length: number): string;
|
|
197
|
+
floating(precision: number, scale: number): string;
|
|
198
|
+
decimal(precision: number, scale: number): string;
|
|
199
|
+
specifictype(type: string): string;
|
|
200
|
+
|
|
201
|
+
nullable(nullable: boolean): string;
|
|
202
|
+
notNullable(): string;
|
|
203
|
+
defaultTo(value: any): string;
|
|
204
|
+
increments(options?: { primaryKey: boolean }): string;
|
|
205
|
+
bigincrements(options?: { primaryKey: boolean }): string;
|
|
206
|
+
|
|
207
|
+
_pushAlterCheckQuery(checkPredicate: string, constraintName: string): void;
|
|
208
|
+
_checkConstraintName(constraintName: string): string;
|
|
209
|
+
_check(checkPredicate: string, constraintName: string): string;
|
|
210
|
+
checkPositive(constraintName: string): string;
|
|
211
|
+
checkNegative(constraintName: string): string;
|
|
212
|
+
_checkIn(values: any[], constraintName: string, not?: boolean): string;
|
|
213
|
+
checkIn(values: any[], constraintName: string): string;
|
|
214
|
+
checkNotIn(values: any[], constraintName: string): string;
|
|
215
|
+
checkBetween(intervals: any[], constraintName: string): string;
|
|
216
|
+
checkLength(
|
|
217
|
+
operator: string,
|
|
218
|
+
length: number,
|
|
219
|
+
constraintName: string,
|
|
220
|
+
): string;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export default ColumnCompiler;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
declare module "knex/lib/schema/compiler" {
|
|
227
|
+
// Eslint gets dumb about this
|
|
228
|
+
// eslint-disable-next-line no-duplicate-imports
|
|
229
|
+
import { Knex } from "knex";
|
|
230
|
+
|
|
231
|
+
class SchemaCompiler {
|
|
232
|
+
constructor(client: Knex.Client, builder?: Knex.TableBuilder);
|
|
233
|
+
|
|
234
|
+
client: Knex.Client;
|
|
235
|
+
builder: Knex.TableBuilder;
|
|
236
|
+
_commonBuilder: Knex.TableBuilder;
|
|
237
|
+
schema: any;
|
|
238
|
+
bindings: any[];
|
|
239
|
+
bindingsHolder: this;
|
|
240
|
+
formatter: any;
|
|
241
|
+
sequence: any[];
|
|
242
|
+
dropTablePrefix: string;
|
|
243
|
+
dropViewPrefix: string;
|
|
244
|
+
dropMaterializedViewPrefix: string;
|
|
245
|
+
alterViewPrefix: string;
|
|
246
|
+
|
|
247
|
+
createSchema(): void;
|
|
248
|
+
createSchemaIfNotExists(): void;
|
|
249
|
+
dropSchema(): void;
|
|
250
|
+
dropSchemaIfExists(): void;
|
|
251
|
+
dropTable(tableName: string): void;
|
|
252
|
+
dropTableIfExists(tableName: string): void;
|
|
253
|
+
dropView(viewName: string): void;
|
|
254
|
+
dropViewIfExists(viewName: string): void;
|
|
255
|
+
dropMaterializedView(viewName: string): void;
|
|
256
|
+
dropMaterializedViewIfExists(viewName: string): void;
|
|
257
|
+
renameView(from: string, to: string): void;
|
|
258
|
+
refreshMaterializedView(): void;
|
|
259
|
+
_dropView(viewName: string, ifExists: boolean, materialized: boolean): void;
|
|
260
|
+
raw(sql: string, bindings: any[]): void;
|
|
261
|
+
toSQL(): any[];
|
|
262
|
+
generateDdlCommands(): Promise<any>;
|
|
263
|
+
alterTable(): any;
|
|
264
|
+
createTable(): any;
|
|
265
|
+
createTableIfNotExists(): any;
|
|
266
|
+
createTableLike(): any;
|
|
267
|
+
createView(): any;
|
|
268
|
+
createViewOrReplace(): any;
|
|
269
|
+
createMaterializedView(): any;
|
|
270
|
+
alterView(): any;
|
|
271
|
+
pushQuery(): void;
|
|
272
|
+
pushAdditional(): void;
|
|
273
|
+
unshiftQuery(): void;
|
|
274
|
+
|
|
275
|
+
pushQuery(
|
|
276
|
+
query: string | { sql: string; bindings: any; output: any },
|
|
277
|
+
): void;
|
|
278
|
+
pushAdditional(fn: any): void;
|
|
279
|
+
unshiftQuery(query: string | { sql: string; bindings: any }): void;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export default SchemaCompiler;
|
|
283
|
+
}
|
|
@@ -4,7 +4,6 @@ import isObject from "lodash/isObject";
|
|
|
4
4
|
import { rawOrFn as rawOrFn_ } from "knex/lib/formatter/wrappingFormatter";
|
|
5
5
|
import { format } from "date-fns";
|
|
6
6
|
import isEmpty from "lodash/isEmpty";
|
|
7
|
-
import * as console from "console";
|
|
8
7
|
|
|
9
8
|
class IBMiQueryCompiler extends QueryCompiler {
|
|
10
9
|
insert() {
|