@bdkinc/knex-ibmi 0.2.2 → 0.2.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 +26 -22
- package/dist/index.d.ts +1 -4
- package/dist/index.js +13 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
This is an external dialect for [knex](https://knexjs.org).
|
|
8
8
|
This library uses the ODBC (as recommended here https://ibmi-oss-docs.readthedocs.io/en/latest/odbc/README.html)
|
|
9
9
|
driver and is only tested on IBMi.
|
|
10
|
+
|
|
10
11
|
For more information on IBMi OSS here are the [docs](https://ibmi-oss-docs.readthedocs.io/en/latest/README.html)
|
|
11
12
|
|
|
12
13
|
## Supported functionality
|
|
@@ -43,15 +44,16 @@ const { DB2Dialect } = require("@bdkinc/knex-ibmi");
|
|
|
43
44
|
const db = knex({
|
|
44
45
|
client: DB2Dialect,
|
|
45
46
|
connection: {
|
|
46
|
-
host: "localhost",
|
|
47
|
-
database: "knextest",
|
|
48
|
-
port: 50000,
|
|
49
|
-
user: "<user>",
|
|
50
|
-
password: "<password>",
|
|
51
|
-
driver: "IBM i Access ODBC Driver",
|
|
52
|
-
connectionStringParams: {
|
|
53
|
-
ALLOWPROCCALLS: 1,
|
|
47
|
+
host: "localhost", // hostname or ip address of server
|
|
48
|
+
database: "knextest", // usually named in your odbc.ini connection
|
|
49
|
+
port: 50000, // default port
|
|
50
|
+
user: "<user>", // IBMi username
|
|
51
|
+
password: "<password>", // IBMi password
|
|
52
|
+
driver: "IBM i Access ODBC Driver", // defined in odbcinst.ini
|
|
53
|
+
connectionStringParams: { // DSN connection string parameters https://www.ibm.com/docs/en/i/7.5?topic=details-connection-string-keywords
|
|
54
|
+
ALLOWPROCCALLS: 1,
|
|
54
55
|
CMT: 0,
|
|
56
|
+
DBQ: 'MYLIB' // library or schema that holds the tables
|
|
55
57
|
},
|
|
56
58
|
},
|
|
57
59
|
pool: {
|
|
@@ -77,15 +79,16 @@ import { DB2Dialect } from "@bdkinc/knex-ibmi";
|
|
|
77
79
|
const db = knex({
|
|
78
80
|
client: DB2Dialect,
|
|
79
81
|
connection: {
|
|
80
|
-
host: "localhost",
|
|
81
|
-
database: "knextest",
|
|
82
|
-
port: 50000,
|
|
83
|
-
user: "<user>",
|
|
84
|
-
password: "<password>",
|
|
85
|
-
driver: "IBM i Access ODBC Driver",
|
|
86
|
-
connectionStringParams: {
|
|
82
|
+
host: "localhost", // hostname or ip address of server
|
|
83
|
+
database: "knextest", // usually named in your odbc.ini connection
|
|
84
|
+
port: 50000, // default port
|
|
85
|
+
user: "<user>", // IBMi username
|
|
86
|
+
password: "<password>", // IBMi password
|
|
87
|
+
driver: "IBM i Access ODBC Driver", // defined in odbcinst.ini
|
|
88
|
+
connectionStringParams: { // DSN connection string parameters https://www.ibm.com/docs/en/i/7.5?topic=details-connection-string-keywords
|
|
87
89
|
ALLOWPROCCALLS: 1,
|
|
88
90
|
CMT: 0,
|
|
91
|
+
DBQ: 'MYLIB' // library or schema that holds the tables
|
|
89
92
|
},
|
|
90
93
|
},
|
|
91
94
|
pool: {
|
|
@@ -113,15 +116,16 @@ import { DB2Dialect, DB2Config } from "@bdkinc/knex-ibmi";
|
|
|
113
116
|
const config: DB2Config = {
|
|
114
117
|
client: DB2Dialect,
|
|
115
118
|
connection: {
|
|
116
|
-
host: "localhost",
|
|
117
|
-
database: "knextest",
|
|
118
|
-
port: 50000,
|
|
119
|
-
user: "<user>",
|
|
120
|
-
password: "<password>",
|
|
121
|
-
driver: "IBM i Access ODBC Driver",
|
|
122
|
-
connectionStringParams: {
|
|
119
|
+
host: "localhost", // hostname or ip address of server
|
|
120
|
+
database: "knextest", // usually named in your odbc.ini connection
|
|
121
|
+
port: 50000, // default port
|
|
122
|
+
user: "<user>", // IBMi username
|
|
123
|
+
password: "<password>", // IBMi password
|
|
124
|
+
driver: "IBM i Access ODBC Driver", // defined in odbcinst.ini
|
|
125
|
+
connectionStringParams: { // DSN connection string parameters https://www.ibm.com/docs/en/i/7.5?topic=details-connection-string-keywords
|
|
123
126
|
ALLOWPROCCALLS: 1,
|
|
124
127
|
CMT: 0,
|
|
128
|
+
DBQ: 'MYLIB' // library or schema that holds the tables
|
|
125
129
|
},
|
|
126
130
|
},
|
|
127
131
|
pool: {
|
package/dist/index.d.ts
CHANGED
|
@@ -40,7 +40,6 @@ declare class IBMiQueryCompiler extends QueryCompiler {
|
|
|
40
40
|
update(): {
|
|
41
41
|
sql: string;
|
|
42
42
|
returning: any;
|
|
43
|
-
selectReturning: string;
|
|
44
43
|
};
|
|
45
44
|
_returning(method: string, value: any, withTrigger: undefined): string | undefined;
|
|
46
45
|
columnizeWithPrefix(prefix: string, target: any): string;
|
|
@@ -94,12 +93,10 @@ interface DB2ConnectionConfig {
|
|
|
94
93
|
driver: "IBM i Access ODBC Driver" | string;
|
|
95
94
|
connectionStringParams?: DB2ConnectionParams;
|
|
96
95
|
}
|
|
97
|
-
interface DB2Config {
|
|
96
|
+
interface DB2Config extends Knex.Config {
|
|
98
97
|
client: any;
|
|
99
98
|
connection: DB2ConnectionConfig;
|
|
100
99
|
pool?: DB2PoolConfig;
|
|
101
|
-
version?: string;
|
|
102
|
-
useNullAsDefault?: boolean;
|
|
103
100
|
}
|
|
104
101
|
declare const DB2Dialect: typeof DB2Client;
|
|
105
102
|
|
package/dist/index.js
CHANGED
|
@@ -271,17 +271,15 @@ var IBMiQueryCompiler = class extends import_querycompiler.default {
|
|
|
271
271
|
const order = this.order();
|
|
272
272
|
const limit = this.limit();
|
|
273
273
|
const { returning } = this.single;
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
const sql = withSQL + `update ${this.single.only ? "only " : ""}${this.tableName} set ` + updates.join(", ") + (where ? ` ${where}` : "") + (order ? ` ${order}` : "") + (limit ? ` ${limit}` : "");
|
|
284
|
-
return { sql, returning, selectReturning };
|
|
274
|
+
let sql = "";
|
|
275
|
+
if (returning) {
|
|
276
|
+
sql += `select ${this.formatter.columnize(this.single.returning)} from FINAL TABLE(`;
|
|
277
|
+
}
|
|
278
|
+
sql += withSQL + `update ${this.single.only ? "only " : ""}${this.tableName} set ` + updates.join(", ") + (where ? ` ${where}` : "") + (order ? ` ${order}` : "") + (limit ? ` ${limit}` : "");
|
|
279
|
+
if (returning) {
|
|
280
|
+
sql += `)`;
|
|
281
|
+
}
|
|
282
|
+
return { sql, returning };
|
|
285
283
|
}
|
|
286
284
|
_returning(method, value, withTrigger) {
|
|
287
285
|
switch (method) {
|
|
@@ -348,11 +346,10 @@ var DB2Client = class extends import_knex.knex.Client {
|
|
|
348
346
|
}
|
|
349
347
|
}
|
|
350
348
|
printError(message) {
|
|
351
|
-
if (
|
|
352
|
-
|
|
353
|
-
this.logger.error("knex-ibmi: " + message);
|
|
354
|
-
}
|
|
349
|
+
if (this.logger.error) {
|
|
350
|
+
this.logger.error("knex-ibmi: " + message);
|
|
355
351
|
}
|
|
352
|
+
throw new Error(message);
|
|
356
353
|
}
|
|
357
354
|
printWarn(message) {
|
|
358
355
|
if (import_node_process.default.env.DEBUG === "true") {
|
|
@@ -448,8 +445,7 @@ var DB2Client = class extends import_knex.knex.Client {
|
|
|
448
445
|
obj.response = { rows: result, rowCount: result.count };
|
|
449
446
|
}
|
|
450
447
|
} catch (err) {
|
|
451
|
-
this.printError(err);
|
|
452
|
-
throw new Error(err);
|
|
448
|
+
this.printError(JSON.stringify(err));
|
|
453
449
|
}
|
|
454
450
|
}
|
|
455
451
|
this.printDebug(obj);
|