@bdkinc/knex-ibmi 0.1.7 → 0.2.2
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 +16 -42
- package/dist/index.d.ts +22 -14
- package/dist/index.js +75 -108
- package/package.json +21 -17
- package/src/execution/ibmi-transaction.js +0 -99
- package/src/execution/ibmi-transaction.ts +0 -21
- package/src/index.ts +0 -293
- package/src/knex-shim.d.ts +0 -283
- package/src/query/ibmi-querycompiler.js +0 -249
- package/src/query/ibmi-querycompiler.ts +0 -219
- package/src/schema/ibmi-columncompiler.js +0 -33
- package/src/schema/ibmi-columncompiler.ts +0 -14
- package/src/schema/ibmi-compiler.js +0 -67
- package/src/schema/ibmi-compiler.ts +0 -52
- package/src/schema/ibmi-tablecompiler.js +0 -166
- package/src/schema/ibmi-tablecompiler.ts +0 -114
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
-
// @ts-ignore
|
|
55
|
-
var transaction_1 = require("knex/lib/execution/transaction");
|
|
56
|
-
var IBMiTransaction = /** @class */ (function (_super) {
|
|
57
|
-
__extends(IBMiTransaction, _super);
|
|
58
|
-
function IBMiTransaction() {
|
|
59
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
60
|
-
}
|
|
61
|
-
IBMiTransaction.prototype.begin = function (connection) {
|
|
62
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
-
return __generator(this, function (_a) {
|
|
64
|
-
switch (_a.label) {
|
|
65
|
-
case 0: return [4 /*yield*/, connection.beginTransaction()];
|
|
66
|
-
case 1:
|
|
67
|
-
_a.sent();
|
|
68
|
-
return [2 /*return*/, connection];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
IBMiTransaction.prototype.rollback = function (connection) {
|
|
74
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
75
|
-
return __generator(this, function (_a) {
|
|
76
|
-
switch (_a.label) {
|
|
77
|
-
case 0: return [4 /*yield*/, connection.rollback()];
|
|
78
|
-
case 1:
|
|
79
|
-
_a.sent();
|
|
80
|
-
return [2 /*return*/, connection];
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
IBMiTransaction.prototype.commit = function (connection) {
|
|
86
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
-
return __generator(this, function (_a) {
|
|
88
|
-
switch (_a.label) {
|
|
89
|
-
case 0: return [4 /*yield*/, connection.commit()];
|
|
90
|
-
case 1:
|
|
91
|
-
_a.sent();
|
|
92
|
-
return [2 /*return*/, connection];
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
return IBMiTransaction;
|
|
98
|
-
}(transaction_1.default));
|
|
99
|
-
exports.default = IBMiTransaction;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
|
-
import Transaction from "knex/lib/execution/transaction";
|
|
3
|
-
|
|
4
|
-
class IBMiTransaction extends Transaction {
|
|
5
|
-
async begin(connection: any) {
|
|
6
|
-
await connection.beginTransaction();
|
|
7
|
-
return connection;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
async rollback(connection: any) {
|
|
11
|
-
await connection.rollback();
|
|
12
|
-
return connection;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async commit(connection: any) {
|
|
16
|
-
await connection.commit();
|
|
17
|
-
return connection;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export default IBMiTransaction;
|
package/src/index.ts
DELETED
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
import * as process from "process";
|
|
2
|
-
import { Connection } from "odbc";
|
|
3
|
-
import { knex, Knex } from "knex";
|
|
4
|
-
import * as odbc from "odbc";
|
|
5
|
-
import SchemaCompiler from "./schema/ibmi-compiler";
|
|
6
|
-
import TableCompiler from "./schema/ibmi-tablecompiler";
|
|
7
|
-
import ColumnCompiler from "./schema/ibmi-columncompiler";
|
|
8
|
-
import Transaction from "./execution/ibmi-transaction";
|
|
9
|
-
import QueryCompiler from "./query/ibmi-querycompiler";
|
|
10
|
-
|
|
11
|
-
class DB2Client extends knex.Client {
|
|
12
|
-
constructor(config: Knex.Config<DB2Config>) {
|
|
13
|
-
super(config);
|
|
14
|
-
this.driverName = "odbc";
|
|
15
|
-
|
|
16
|
-
if (this.dialect && !this.config.client) {
|
|
17
|
-
this.printWarn(
|
|
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.`,
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const dbClient = this.config.client || this.dialect;
|
|
23
|
-
if (!dbClient) {
|
|
24
|
-
throw new Error(
|
|
25
|
-
`knex: Required configuration option 'client' is missing.`,
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (config.version) {
|
|
30
|
-
this.version = config.version;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (this.driverName && config.connection) {
|
|
34
|
-
this.initializeDriver();
|
|
35
|
-
if (!config.pool || (config.pool && config.pool.max !== 0)) {
|
|
36
|
-
this.initializePool(config);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
this.valueForUndefined = this.raw("DEFAULT");
|
|
40
|
-
if (config.useNullAsDefault) {
|
|
41
|
-
this.valueForUndefined = null;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
_driver() {
|
|
46
|
-
return odbc;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
printDebug(message: string) {
|
|
50
|
-
if (process.env.DEBUG === "true") {
|
|
51
|
-
// @ts-ignore
|
|
52
|
-
this.logger.debug("knex-ibmi: " + message);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
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
|
-
|
|
70
|
-
// Get a raw connection, called by the pool manager whenever a new
|
|
71
|
-
// connection needs to be added to the pool.
|
|
72
|
-
async acquireRawConnection() {
|
|
73
|
-
this.printDebug("acquiring raw connection");
|
|
74
|
-
const connectionConfig = this.config.connection;
|
|
75
|
-
|
|
76
|
-
this.printDebug(
|
|
77
|
-
// @ts-ignore
|
|
78
|
-
"connection config: " + this._getConnectionString(connectionConfig),
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
if (this.config?.pool) {
|
|
82
|
-
// @ts-ignore
|
|
83
|
-
const poolConfig = {
|
|
84
|
-
// @ts-ignore
|
|
85
|
-
connectionString: this._getConnectionString(connectionConfig),
|
|
86
|
-
connectionTimeout: this.config?.acquireConnectionTimeout || 60000,
|
|
87
|
-
initialSize: this.config?.pool?.min || 2,
|
|
88
|
-
maxSize: this.config?.pool?.max || 10,
|
|
89
|
-
reuseConnection: true,
|
|
90
|
-
};
|
|
91
|
-
const pool = await this.driver.pool(poolConfig);
|
|
92
|
-
return await pool.connect();
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return await this.driver.connect(
|
|
96
|
-
// @ts-ignore
|
|
97
|
-
this._getConnectionString(connectionConfig),
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Used to explicitly close a connection, called internally by the pool manager
|
|
102
|
-
// when a connection times out or the pool is shutdown.
|
|
103
|
-
async destroyRawConnection(connection: Connection) {
|
|
104
|
-
this.printDebug("destroy connection");
|
|
105
|
-
return await connection.close();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
_getConnectionString(connectionConfig: DB2ConnectionConfig) {
|
|
109
|
-
const connectionStringParams =
|
|
110
|
-
connectionConfig.connectionStringParams || {};
|
|
111
|
-
const connectionStringExtension = Object.keys(
|
|
112
|
-
connectionStringParams,
|
|
113
|
-
).reduce((result, key) => {
|
|
114
|
-
const value = connectionStringParams[key];
|
|
115
|
-
return `${result}${key}=${value};`;
|
|
116
|
-
}, "");
|
|
117
|
-
|
|
118
|
-
return `${
|
|
119
|
-
`DRIVER=${connectionConfig.driver};SYSTEM=${connectionConfig.host};HOSTNAME=${connectionConfig.host};` +
|
|
120
|
-
`PORT=${connectionConfig.port};DATABASE=${connectionConfig.database};` +
|
|
121
|
-
`UID=${connectionConfig.user};PWD=${connectionConfig.password};`
|
|
122
|
-
}${connectionStringExtension}`;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Runs the query on the specified connection, providing the bindings
|
|
126
|
-
async _query(connection: any, obj: any) {
|
|
127
|
-
if (!obj || typeof obj == "string") obj = { sql: obj };
|
|
128
|
-
const method = (
|
|
129
|
-
obj.hasOwnProperty("method") && obj.method !== "raw"
|
|
130
|
-
? obj.method
|
|
131
|
-
: obj.sql.split(" ")[0]
|
|
132
|
-
).toLowerCase();
|
|
133
|
-
obj.sqlMethod = method;
|
|
134
|
-
|
|
135
|
-
if (method === "select" || method === "first" || method === "pluck") {
|
|
136
|
-
const rows: any = await connection.query(obj.sql, obj.bindings);
|
|
137
|
-
if (rows) {
|
|
138
|
-
obj.response = { rows, rowCount: rows.length };
|
|
139
|
-
}
|
|
140
|
-
} else {
|
|
141
|
-
try {
|
|
142
|
-
const statement = await connection.createStatement();
|
|
143
|
-
await statement.prepare(obj.sql);
|
|
144
|
-
|
|
145
|
-
if (obj.bindings) {
|
|
146
|
-
await statement.bind(obj.bindings);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const result = await statement.execute();
|
|
150
|
-
this.printDebug(result);
|
|
151
|
-
// this is hacky we check the SQL for the ID column
|
|
152
|
-
// we check for the IDENTITY scalar function
|
|
153
|
-
// if that function is present, then we just return the value of the
|
|
154
|
-
// IDENTITY column
|
|
155
|
-
if (result.statement.includes("IDENTITY_VAL_LOCAL()")) {
|
|
156
|
-
obj.response = {
|
|
157
|
-
rows: result.map((row: { [x: string]: any }) =>
|
|
158
|
-
result.columns && result.columns?.length > 0
|
|
159
|
-
? row[result.columns[0].name]
|
|
160
|
-
: row,
|
|
161
|
-
),
|
|
162
|
-
rowCount: result.count,
|
|
163
|
-
};
|
|
164
|
-
} else if (method === "update") {
|
|
165
|
-
if (obj.selectReturning) {
|
|
166
|
-
const returningSelect = await connection.query(obj.selectReturning);
|
|
167
|
-
obj.response = {
|
|
168
|
-
rows: returningSelect,
|
|
169
|
-
rowCount: result.count,
|
|
170
|
-
};
|
|
171
|
-
} else {
|
|
172
|
-
obj.response = {
|
|
173
|
-
rows: result,
|
|
174
|
-
rowCount: result.count,
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
} else {
|
|
178
|
-
obj.response = { rows: result, rowCount: result.count };
|
|
179
|
-
}
|
|
180
|
-
} catch (err: any) {
|
|
181
|
-
this.printDebug(err);
|
|
182
|
-
console.error(err)
|
|
183
|
-
throw new Error(err)
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
this.printDebug(obj);
|
|
188
|
-
|
|
189
|
-
return obj;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
transaction(container: any, config: any, outerTx: any): Knex.Transaction {
|
|
193
|
-
// @ts-ignore
|
|
194
|
-
return new Transaction(this, ...arguments);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
schemaCompiler() {
|
|
198
|
-
// @ts-ignore
|
|
199
|
-
return new SchemaCompiler(this, ...arguments);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
tableCompiler() {
|
|
203
|
-
// @ts-ignore
|
|
204
|
-
return new TableCompiler(this, ...arguments);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
columnCompiler() {
|
|
208
|
-
// @ts-ignore
|
|
209
|
-
return new ColumnCompiler(this, ...arguments);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
queryCompiler() {
|
|
213
|
-
// @ts-ignore
|
|
214
|
-
return new QueryCompiler(this, ...arguments);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
processResponse(obj: any, runner: any) {
|
|
218
|
-
if (obj === null) return null;
|
|
219
|
-
|
|
220
|
-
const resp = obj.response;
|
|
221
|
-
const method = obj.sqlMethod;
|
|
222
|
-
if (!resp) {
|
|
223
|
-
this.printDebug("response undefined" + obj);
|
|
224
|
-
}
|
|
225
|
-
const { rows, rowCount } = resp;
|
|
226
|
-
|
|
227
|
-
if (obj.output) return obj.output.call(runner, resp);
|
|
228
|
-
|
|
229
|
-
switch (method) {
|
|
230
|
-
case "select":
|
|
231
|
-
return rows;
|
|
232
|
-
case "pluck":
|
|
233
|
-
return rows.map(obj.pluck);
|
|
234
|
-
case "first":
|
|
235
|
-
return rows[0];
|
|
236
|
-
case "insert":
|
|
237
|
-
return rows;
|
|
238
|
-
case "del":
|
|
239
|
-
case "delete":
|
|
240
|
-
case "update":
|
|
241
|
-
if (obj.selectReturning) {
|
|
242
|
-
return rows;
|
|
243
|
-
}
|
|
244
|
-
return rowCount;
|
|
245
|
-
case "counter":
|
|
246
|
-
return rowCount;
|
|
247
|
-
default:
|
|
248
|
-
return rows;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
interface DB2PoolConfig {
|
|
254
|
-
min?: number;
|
|
255
|
-
max?: number;
|
|
256
|
-
acquireConnectionTimeout?: number;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
interface DB2ConnectionParams {
|
|
260
|
-
CMT?: number;
|
|
261
|
-
CONNTYPE?: number;
|
|
262
|
-
DBQ?: string;
|
|
263
|
-
MAXDECPREC?: 31 | 63;
|
|
264
|
-
MAXDECSCALE?: number;
|
|
265
|
-
MINDIVSCALE?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
266
|
-
NAM?: 0 | 1;
|
|
267
|
-
DFT?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
268
|
-
DSP?: 0 | 1 | 2 | 3 | 4;
|
|
269
|
-
DEC?: 0 | 1;
|
|
270
|
-
DECFLOATERROROPTION?: 0 | 1;
|
|
271
|
-
DECFLOATROUNDMODE?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
272
|
-
MAPDECIMALFLOATDESCRIBE?: 1 | 3;
|
|
273
|
-
ALLOWPROCCALLS?: 0 | 1;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
interface DB2ConnectionConfig {
|
|
277
|
-
database: string;
|
|
278
|
-
host: string;
|
|
279
|
-
port: 50000 | number;
|
|
280
|
-
user: string;
|
|
281
|
-
password: string;
|
|
282
|
-
driver: "IBM i Access ODBC Driver" | string;
|
|
283
|
-
connectionStringParams?: DB2ConnectionParams;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
export interface DB2Config {
|
|
287
|
-
client: any;
|
|
288
|
-
connection: DB2ConnectionConfig;
|
|
289
|
-
pool?: DB2PoolConfig;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
export const DB2Dialect = DB2Client;
|
|
293
|
-
export default DB2Client;
|
package/src/knex-shim.d.ts
DELETED
|
@@ -1,283 +0,0 @@
|
|
|
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
|
-
}
|