stimulsoft-data-adapter 2022.4.5 → 2023.1.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/FirebirdAdapter.js +44 -4
- package/MSSQLAdapter.js +63 -4
- package/MySQLAdapter.js +50 -13
- package/PostgreSQLAdapter.js +48 -6
- package/index.js +8 -41
- package/package.json +1 -1
package/FirebirdAdapter.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/*
|
|
2
2
|
Stimulsoft.Reports.JS
|
|
3
|
-
Version:
|
|
4
|
-
Build date: 2022.
|
|
3
|
+
Version: 2023.1.2
|
|
4
|
+
Build date: 2022.12.15
|
|
5
5
|
License: https://www.stimulsoft.com/en/licensing/reports
|
|
6
6
|
*/
|
|
7
7
|
exports.process = function (command, onResult) {
|
|
8
8
|
var end = function (result) {
|
|
9
9
|
try {
|
|
10
10
|
if (db) db.detach();
|
|
11
|
-
result.adapterVersion = "
|
|
11
|
+
result.adapterVersion = "2023.1.2";
|
|
12
12
|
onResult(result);
|
|
13
13
|
}
|
|
14
14
|
catch (e) {
|
|
@@ -37,7 +37,10 @@ exports.process = function (command, onResult) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
var onConnect = function () {
|
|
40
|
-
if (command.queryString)
|
|
40
|
+
if (command.queryString) {
|
|
41
|
+
var queryString = applyQueryParameters(command.queryString, command.parameters, command.escapeQueryParameters);
|
|
42
|
+
query(queryString);
|
|
43
|
+
}
|
|
41
44
|
else end({ success: true });
|
|
42
45
|
}
|
|
43
46
|
|
|
@@ -126,6 +129,43 @@ exports.process = function (command, onResult) {
|
|
|
126
129
|
return info;
|
|
127
130
|
};
|
|
128
131
|
|
|
132
|
+
var applyQueryParameters = function (baseSqlCommand, parameters, escapeQueryParameters) {
|
|
133
|
+
if (baseSqlCommand == null || baseSqlCommand.indexOf("@") < 0) return baseSqlCommand;
|
|
134
|
+
|
|
135
|
+
var result = "";
|
|
136
|
+
while (baseSqlCommand.indexOf("@") >= 0 && parameters != null && parameters.length > 0) {
|
|
137
|
+
result += baseSqlCommand.substring(0, baseSqlCommand.indexOf("@"));
|
|
138
|
+
baseSqlCommand = baseSqlCommand.substring(baseSqlCommand.indexOf("@") + 1);
|
|
139
|
+
|
|
140
|
+
var parameterName = "";
|
|
141
|
+
|
|
142
|
+
while (baseSqlCommand.length > 0) {
|
|
143
|
+
var char = baseSqlCommand.charAt(0);
|
|
144
|
+
if (char.length === 1 && char.match(/[a-zA-Z0-9_-]/i)) {
|
|
145
|
+
parameterName += char;
|
|
146
|
+
baseSqlCommand = baseSqlCommand.substring(1);
|
|
147
|
+
}
|
|
148
|
+
else break;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
var parameter = parameters.find(parameter => parameter.name.toLowerCase() == parameterName.toLowerCase());
|
|
152
|
+
if (parameter) {
|
|
153
|
+
if (parameter.typeGroup != "number") {
|
|
154
|
+
if (escapeQueryParameters)
|
|
155
|
+
result += "'" + parameter.value.toString().replace(/\\/gi, "\\\\").replace(/\'/gi, "\\\'").replace(/\"/gi, "\\\"") + "'";
|
|
156
|
+
else
|
|
157
|
+
result += "'" + parameter.value.toString() + "'";
|
|
158
|
+
}
|
|
159
|
+
else
|
|
160
|
+
result += parameter.value.toString();
|
|
161
|
+
}
|
|
162
|
+
else
|
|
163
|
+
result += "@" + parameterName;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return result + baseSqlCommand;
|
|
167
|
+
}
|
|
168
|
+
|
|
129
169
|
var Firebird = require('node-firebird');
|
|
130
170
|
command.connectionStringInfo = getConnectionStringInfo(command.connectionString);
|
|
131
171
|
if (command.connectionStringInfo) {
|
package/MSSQLAdapter.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/*
|
|
2
2
|
Stimulsoft.Reports.JS
|
|
3
|
-
Version:
|
|
4
|
-
Build date: 2022.
|
|
3
|
+
Version: 2023.1.2
|
|
4
|
+
Build date: 2022.12.15
|
|
5
5
|
License: https://www.stimulsoft.com/en/licensing/reports
|
|
6
6
|
*/
|
|
7
7
|
exports.process = function (command, onResult) {
|
|
8
8
|
var end = function (result) {
|
|
9
9
|
try {
|
|
10
10
|
if (connection) connection.close();
|
|
11
|
-
result.adapterVersion = "
|
|
11
|
+
result.adapterVersion = "2023.1.2";
|
|
12
12
|
onResult(result);
|
|
13
13
|
}
|
|
14
14
|
catch (e) {
|
|
@@ -37,8 +37,31 @@ exports.process = function (command, onResult) {
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
var execute = function (queryString, parameters) {
|
|
41
|
+
var request = connection.request();
|
|
42
|
+
|
|
43
|
+
for (var index in parameters) {
|
|
44
|
+
var parameter = parameters[index];
|
|
45
|
+
request.input(parameter.name, sql[parameter.typeName], parameter.value);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
request.execute(queryString, function (error, recordset) {
|
|
49
|
+
if (error) onError(error.message);
|
|
50
|
+
else {
|
|
51
|
+
onQuery(recordset);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
40
56
|
var onConnect = function () {
|
|
41
|
-
if (command.queryString)
|
|
57
|
+
if (command.queryString) {
|
|
58
|
+
if (command.command == "Execute")
|
|
59
|
+
execute(command.queryString, command.parameters);
|
|
60
|
+
else {
|
|
61
|
+
var queryString = applyQueryParameters(command.queryString, command.parameters, command.escapeQueryParameters);
|
|
62
|
+
query(queryString);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
42
65
|
else end({ success: true });
|
|
43
66
|
}
|
|
44
67
|
|
|
@@ -141,6 +164,42 @@ exports.process = function (command, onResult) {
|
|
|
141
164
|
end({ success: true, columns: columns, rows: rows, types: types });
|
|
142
165
|
}
|
|
143
166
|
|
|
167
|
+
var applyQueryParameters = function (baseSqlCommand, parameters, escapeQueryParameters) {
|
|
168
|
+
if (baseSqlCommand == null || baseSqlCommand.indexOf("@") < 0) return baseSqlCommand;
|
|
169
|
+
|
|
170
|
+
var result = "";
|
|
171
|
+
while (baseSqlCommand.indexOf("@") >= 0 && parameters != null && parameters.length > 0) {
|
|
172
|
+
result += baseSqlCommand.substring(0, baseSqlCommand.indexOf("@"));
|
|
173
|
+
baseSqlCommand = baseSqlCommand.substring(baseSqlCommand.indexOf("@") + 1);
|
|
174
|
+
|
|
175
|
+
var parameterName = "";
|
|
176
|
+
|
|
177
|
+
while (baseSqlCommand.length > 0) {
|
|
178
|
+
var char = baseSqlCommand.charAt(0);
|
|
179
|
+
if (char.length === 1 && char.match(/[a-zA-Z0-9_-]/i)) {
|
|
180
|
+
parameterName += char;
|
|
181
|
+
baseSqlCommand = baseSqlCommand.substring(1);
|
|
182
|
+
}
|
|
183
|
+
else break;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
var parameter = parameters.find(parameter => parameter.name.toLowerCase() == parameterName.toLowerCase());
|
|
187
|
+
if (parameter) {
|
|
188
|
+
if (parameter.typeGroup != "number") {
|
|
189
|
+
if (escapeQueryParameters)
|
|
190
|
+
result += "'" + parameter.value.toString().replace(/\\/gi, "\\\\").replace(/\'/gi, "\\\'").replace(/\"/gi, "\\\"") + "'";
|
|
191
|
+
else
|
|
192
|
+
result += "'" + parameter.value.toString() + "'";
|
|
193
|
+
}
|
|
194
|
+
else
|
|
195
|
+
result += parameter.value.toString();
|
|
196
|
+
}
|
|
197
|
+
else
|
|
198
|
+
result += "@" + parameterName;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return result + baseSqlCommand;
|
|
202
|
+
}
|
|
144
203
|
var getHostInfo = function (host) {
|
|
145
204
|
const info = {};
|
|
146
205
|
const regexPort = /(.*),([0-9]+)/;
|
package/MySQLAdapter.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
/*
|
|
2
2
|
Stimulsoft.Reports.JS
|
|
3
|
-
Version:
|
|
4
|
-
Build date: 2022.
|
|
3
|
+
Version: 2023.1.2
|
|
4
|
+
Build date: 2022.12.15
|
|
5
5
|
License: https://www.stimulsoft.com/en/licensing/reports
|
|
6
6
|
*/
|
|
7
7
|
exports.process = function (command, onResult) {
|
|
8
8
|
var end = function (result) {
|
|
9
9
|
try {
|
|
10
|
-
if (connection)
|
|
10
|
+
if (connection)
|
|
11
11
|
connection.end();
|
|
12
|
-
}
|
|
13
|
-
result.adapterVersion = "2022.4.5";
|
|
14
|
-
onResult(result);
|
|
15
12
|
}
|
|
16
13
|
catch (e) {
|
|
17
14
|
}
|
|
15
|
+
finally {
|
|
16
|
+
result.adapterVersion = "2023.1.2";
|
|
17
|
+
onResult(result);
|
|
18
|
+
}
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
var onError = function (message) {
|
|
@@ -29,10 +30,9 @@ exports.process = function (command, onResult) {
|
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
var query = function (queryString, timeout) {
|
|
33
|
+
var query = function (queryString, parameters, timeout) {
|
|
33
34
|
connection.query("USE " + command.connectionStringInfo.database);
|
|
34
|
-
|
|
35
|
-
connection.query({ sql: queryString, timeout: timeout }, function (error, rows, fields) {
|
|
35
|
+
connection.query({ sql: queryString, timeout: timeout }, parameters, function (error, rows, fields) {
|
|
36
36
|
if (error) onError(error.message);
|
|
37
37
|
else {
|
|
38
38
|
onQuery(rows, fields);
|
|
@@ -41,7 +41,13 @@ exports.process = function (command, onResult) {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
var onConnect = function () {
|
|
44
|
-
if (command.queryString)
|
|
44
|
+
if (command.queryString) {
|
|
45
|
+
if (command.command == "Execute")
|
|
46
|
+
command.queryString = "CALL " + command.queryString + "(" + command.parameters.map(parameter => "@" + parameter.name).join(", ") + ")";
|
|
47
|
+
|
|
48
|
+
var { queryString, parameters } = applyQueryParameters(command.queryString, command.parameters, command.escapeQueryParameters);
|
|
49
|
+
query(queryString, parameters, command.timeout);
|
|
50
|
+
}
|
|
45
51
|
else end({ success: true });
|
|
46
52
|
}
|
|
47
53
|
|
|
@@ -55,7 +61,7 @@ exports.process = function (command, onResult) {
|
|
|
55
61
|
var column = fields[columnIndex]
|
|
56
62
|
columns.push(column.name);
|
|
57
63
|
|
|
58
|
-
switch (column.
|
|
64
|
+
switch (column.columnType) {
|
|
59
65
|
case 16: // Bit
|
|
60
66
|
types[columnIndex] = "boolean"; break;
|
|
61
67
|
|
|
@@ -191,6 +197,39 @@ exports.process = function (command, onResult) {
|
|
|
191
197
|
return info;
|
|
192
198
|
};
|
|
193
199
|
|
|
200
|
+
var applyQueryParameters = function (baseSqlCommand, baseParameters, escapeQueryParameters) {
|
|
201
|
+
var parameters = [];
|
|
202
|
+
var result = "";
|
|
203
|
+
|
|
204
|
+
if (baseSqlCommand != null && baseSqlCommand.indexOf("@") > -1) {
|
|
205
|
+
while (baseSqlCommand.indexOf("@") >= 0 && baseParameters != null && baseParameters.length > 0) {
|
|
206
|
+
result += baseSqlCommand.substring(0, baseSqlCommand.indexOf("@"));
|
|
207
|
+
baseSqlCommand = baseSqlCommand.substring(baseSqlCommand.indexOf("@") + 1);
|
|
208
|
+
|
|
209
|
+
var parameterName = "";
|
|
210
|
+
|
|
211
|
+
while (baseSqlCommand.length > 0) {
|
|
212
|
+
var char = baseSqlCommand.charAt(0);
|
|
213
|
+
if (char.length === 1 && char.match(/[a-zA-Z0-9_-]/i)) {
|
|
214
|
+
parameterName += char;
|
|
215
|
+
baseSqlCommand = baseSqlCommand.substring(1);
|
|
216
|
+
}
|
|
217
|
+
else break;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
var parameter = baseParameters.find(parameter => parameter.name.toLowerCase() == parameterName.toLowerCase());
|
|
221
|
+
if (parameter) {
|
|
222
|
+
result += "?";
|
|
223
|
+
parameters.push(parameter.value);
|
|
224
|
+
}
|
|
225
|
+
else
|
|
226
|
+
result += "@" + parameterName;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return { queryString: result + baseSqlCommand, parameters };
|
|
231
|
+
}
|
|
232
|
+
|
|
194
233
|
var mysql = require('mysql2');
|
|
195
234
|
command.connectionStringInfo = getConnectionStringInfo(command.connectionString);
|
|
196
235
|
|
|
@@ -204,8 +243,6 @@ exports.process = function (command, onResult) {
|
|
|
204
243
|
});
|
|
205
244
|
|
|
206
245
|
connect();
|
|
207
|
-
|
|
208
|
-
|
|
209
246
|
}
|
|
210
247
|
catch (e) {
|
|
211
248
|
onError(e.stack);
|
package/PostgreSQLAdapter.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/*
|
|
2
2
|
Stimulsoft.Reports.JS
|
|
3
|
-
Version:
|
|
4
|
-
Build date: 2022.
|
|
3
|
+
Version: 2023.1.2
|
|
4
|
+
Build date: 2022.12.15
|
|
5
5
|
License: https://www.stimulsoft.com/en/licensing/reports
|
|
6
6
|
*/
|
|
7
7
|
exports.process = function (command, onResult) {
|
|
8
8
|
var end = function (result) {
|
|
9
9
|
try {
|
|
10
10
|
if (client) client.end();
|
|
11
|
-
result.adapterVersion = "
|
|
11
|
+
result.adapterVersion = "2023.1.2";
|
|
12
12
|
onResult(result);
|
|
13
13
|
}
|
|
14
14
|
catch (e) {
|
|
@@ -27,8 +27,8 @@ exports.process = function (command, onResult) {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
var query = function (queryString) {
|
|
31
|
-
client.query(queryString, function (error, recordset) {
|
|
30
|
+
var query = function (queryString, parameters) {
|
|
31
|
+
client.query(queryString, parameters, function (error, recordset) {
|
|
32
32
|
if (error) onError(error.message);
|
|
33
33
|
else {
|
|
34
34
|
onQuery(recordset);
|
|
@@ -37,7 +37,13 @@ exports.process = function (command, onResult) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
var onConnect = function () {
|
|
40
|
-
if (command.queryString)
|
|
40
|
+
if (command.queryString) {
|
|
41
|
+
if (command.command == "Execute")
|
|
42
|
+
command.queryString = "CALL " + command.queryString + "(" + command.parameters.map(parameter => "@" + parameter.name).join(", ") +")";
|
|
43
|
+
|
|
44
|
+
var {queryString, parameters} = applyQueryParameters(command.queryString, command.parameters, command.escapeQueryParameters);
|
|
45
|
+
query(queryString, parameters);
|
|
46
|
+
}
|
|
41
47
|
else end({ success: true });
|
|
42
48
|
}
|
|
43
49
|
|
|
@@ -227,6 +233,42 @@ exports.process = function (command, onResult) {
|
|
|
227
233
|
return info;
|
|
228
234
|
};
|
|
229
235
|
|
|
236
|
+
var applyQueryParameters = function (baseSqlCommand, baseParameters, escapeQueryParameters) {
|
|
237
|
+
var parameters = [];
|
|
238
|
+
var result = "";
|
|
239
|
+
|
|
240
|
+
if (baseSqlCommand != null && baseSqlCommand.indexOf("@") > -1) {
|
|
241
|
+
while (baseSqlCommand.indexOf("@") >= 0 && baseParameters != null && baseParameters.length > 0) {
|
|
242
|
+
result += baseSqlCommand.substring(0, baseSqlCommand.indexOf("@"));
|
|
243
|
+
baseSqlCommand = baseSqlCommand.substring(baseSqlCommand.indexOf("@") + 1);
|
|
244
|
+
|
|
245
|
+
var parameterName = "";
|
|
246
|
+
|
|
247
|
+
while (baseSqlCommand.length > 0) {
|
|
248
|
+
var char = baseSqlCommand.charAt(0);
|
|
249
|
+
if (char.length === 1 && char.match(/[a-zA-Z0-9_-]/i)) {
|
|
250
|
+
parameterName += char;
|
|
251
|
+
baseSqlCommand = baseSqlCommand.substring(1);
|
|
252
|
+
}
|
|
253
|
+
else break;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
var parameter = baseParameters.find(parameter => parameter.name.toLowerCase() == parameterName.toLowerCase());
|
|
257
|
+
if (parameter) {
|
|
258
|
+
if (parameter.index == null) {
|
|
259
|
+
parameters.push(parameter.value);
|
|
260
|
+
parameter.index = parameters.length;
|
|
261
|
+
}
|
|
262
|
+
result += '"' + parameter.name +'" := $' + parameter.index.toString();
|
|
263
|
+
}
|
|
264
|
+
else
|
|
265
|
+
result += "@" + parameterName;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return { queryString: result + baseSqlCommand, parameters };
|
|
270
|
+
}
|
|
271
|
+
|
|
230
272
|
var pg = require('pg');
|
|
231
273
|
if (command.connectionString.startsWith("postgres://")) command.postgreConnectionString = command.connectionString
|
|
232
274
|
else {
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
Stimulsoft.Reports.JS
|
|
3
|
-
Version:
|
|
4
|
-
Build date: 2022.
|
|
3
|
+
Version: 2023.1.2
|
|
4
|
+
Build date: 2022.12.15
|
|
5
5
|
License: https://www.stimulsoft.com/en/licensing/reports
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -27,7 +27,11 @@ function process(command, onResult) {
|
|
|
27
27
|
if (command.command === "GetSupportedAdapters") {
|
|
28
28
|
onProcessHandler({ success: true, types: ["MySQL", "MS SQL", "Firebird", "PostgreSQL"] });
|
|
29
29
|
} else {
|
|
30
|
-
|
|
30
|
+
if (command.parameters){
|
|
31
|
+
command.parameters.forEach(parameter => {
|
|
32
|
+
if (parameter.name.length > 1 && parameter.name[0] == "@") parameter.name = parameter.name.substring(1);
|
|
33
|
+
})
|
|
34
|
+
}
|
|
31
35
|
|
|
32
36
|
if (command.database == "MySQL") {
|
|
33
37
|
var MySQLAdapter = require('./MySQLAdapter');
|
|
@@ -49,43 +53,6 @@ function process(command, onResult) {
|
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
55
|
|
|
52
|
-
function applyQueryParameters(baseSqlCommand, parameters, escapeQueryParameters) {
|
|
53
|
-
if (baseSqlCommand == null || baseSqlCommand.indexOf("@") < 0) return baseSqlCommand;
|
|
54
|
-
|
|
55
|
-
var result = "";
|
|
56
|
-
while (baseSqlCommand.indexOf("@") >= 0 && parameters != null && parameters.length > 0) {
|
|
57
|
-
result += baseSqlCommand.substring(0, baseSqlCommand.indexOf("@"));
|
|
58
|
-
baseSqlCommand = baseSqlCommand.substring(baseSqlCommand.indexOf("@") + 1);
|
|
59
|
-
|
|
60
|
-
var parameterName = "";
|
|
61
|
-
|
|
62
|
-
while (baseSqlCommand.length > 0) {
|
|
63
|
-
var char = baseSqlCommand.charAt(0);
|
|
64
|
-
if (char.length === 1 && char.match(/[a-zA-Z0-9_-]/i)) {
|
|
65
|
-
parameterName += char;
|
|
66
|
-
baseSqlCommand = baseSqlCommand.substring(1);
|
|
67
|
-
}
|
|
68
|
-
else break;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
var parameter = parameters.find(parameter => parameter.name.toLowerCase() == parameterName.toLowerCase());
|
|
72
|
-
if (parameter) {
|
|
73
|
-
if (parameter.typeGroup != "number") {
|
|
74
|
-
if (escapeQueryParameters)
|
|
75
|
-
result += "'" + parameter.value.toString().replace(/\\/gi, "\\\\").replace(/\'/gi, "\\\'").replace(/\"/gi, "\\\"") + "'";
|
|
76
|
-
else
|
|
77
|
-
result += "'" + parameter.value.toString() + "'";
|
|
78
|
-
}
|
|
79
|
-
else
|
|
80
|
-
result += parameter.value.toString();
|
|
81
|
-
}
|
|
82
|
-
else
|
|
83
|
-
result += "@" + parameterName;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return result + baseSqlCommand;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
56
|
function getResponse(result) {
|
|
90
57
|
let encryptData = result.encryptData;
|
|
91
58
|
delete result.encryptData;
|
|
@@ -100,7 +67,7 @@ function getResponse(result) {
|
|
|
100
67
|
return result
|
|
101
68
|
}
|
|
102
69
|
function onProcess(onResult, encryptData, result) {
|
|
103
|
-
result.handlerVersion = "
|
|
70
|
+
result.handlerVersion = "2023.1.2";
|
|
104
71
|
result.checkVersion = true;
|
|
105
72
|
result.encryptData = encryptData;
|
|
106
73
|
onResult(result);
|