stimulsoft-data-adapter 2021.3.7 → 2021.4.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/FirebirdAdapter.js +147 -141
- package/MSSQLAdapter.js +248 -229
- package/MySQLAdapter.js +207 -201
- package/PostgreSQLAdapter.js +246 -240
- package/app.js +89 -82
- package/package.json +50 -50
package/MySQLAdapter.js
CHANGED
|
@@ -1,202 +1,208 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
case
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
case
|
|
63
|
-
case
|
|
64
|
-
case
|
|
65
|
-
case
|
|
66
|
-
case
|
|
67
|
-
case
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
case
|
|
71
|
-
case
|
|
72
|
-
case
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
case
|
|
77
|
-
case
|
|
78
|
-
case
|
|
79
|
-
types[columnIndex] = "
|
|
80
|
-
|
|
81
|
-
case
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
case
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
case
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
case
|
|
91
|
-
case
|
|
92
|
-
case
|
|
93
|
-
case
|
|
94
|
-
case
|
|
95
|
-
case
|
|
96
|
-
case
|
|
97
|
-
case
|
|
98
|
-
case
|
|
99
|
-
case
|
|
100
|
-
case
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if (recordset[recordIndex][columnName]
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
case "
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
case "
|
|
161
|
-
case "
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
case "
|
|
168
|
-
case "
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
1
|
+
/*
|
|
2
|
+
Stimulsoft.Reports.JS
|
|
3
|
+
Version: 2021.4.4
|
|
4
|
+
Build date: 2021.11.18
|
|
5
|
+
License: https://www.stimulsoft.com/en/licensing/reports
|
|
6
|
+
*/
|
|
7
|
+
exports.process = function (command, onResult) {
|
|
8
|
+
var end = function (result) {
|
|
9
|
+
try {
|
|
10
|
+
if (connection) {
|
|
11
|
+
connection.end();
|
|
12
|
+
}
|
|
13
|
+
result.adapterVersion = "2021.4.4";
|
|
14
|
+
onResult(result);
|
|
15
|
+
}
|
|
16
|
+
catch (e) {
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var onError = function (message) {
|
|
21
|
+
end({ success: false, notice: message });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
var connect = function () {
|
|
26
|
+
connection.connect(function (error) {
|
|
27
|
+
if (error) onError(error.message);
|
|
28
|
+
else onConnect();
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var query = function (queryString, timeout) {
|
|
33
|
+
connection.query("USE " + command.connectionStringInfo.database);
|
|
34
|
+
//queryString = queryString.replace(/\'/gi, "\"");
|
|
35
|
+
connection.query({ sql: queryString, timeout: timeout }, function (error, rows, fields) {
|
|
36
|
+
if (error) onError(error.message);
|
|
37
|
+
else {
|
|
38
|
+
onQuery(rows, fields);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
var onConnect = function () {
|
|
44
|
+
if (command.queryString) query(command.queryString, command.timeout);
|
|
45
|
+
else end({ success: true });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var onQuery = function (recordset, fields) {
|
|
49
|
+
var columns = [];
|
|
50
|
+
var rows = [];
|
|
51
|
+
var types = [];
|
|
52
|
+
if (fields.length > 0 && Array.isArray(fields[0])) fields = fields[0];
|
|
53
|
+
|
|
54
|
+
for (var columnIndex in fields) {
|
|
55
|
+
var column = fields[columnIndex]
|
|
56
|
+
columns.push(column.name);
|
|
57
|
+
|
|
58
|
+
switch (column.type) {
|
|
59
|
+
case 16: // Bit
|
|
60
|
+
types[columnIndex] = "boolean"; break;
|
|
61
|
+
|
|
62
|
+
case 1: // Byte
|
|
63
|
+
case 2: // Int16
|
|
64
|
+
case 3: // Int32
|
|
65
|
+
case 5: // Double
|
|
66
|
+
case 8: // Int64
|
|
67
|
+
case 9: // Int24
|
|
68
|
+
case 13: // Year
|
|
69
|
+
case 501: // UByte
|
|
70
|
+
case 502: // UInt16
|
|
71
|
+
case 503: // UInt32
|
|
72
|
+
case 508: // UInt64
|
|
73
|
+
case 509: // UInt24
|
|
74
|
+
types[columnIndex] = "int"; break;
|
|
75
|
+
|
|
76
|
+
case 0: // Decimal
|
|
77
|
+
case 4: // Float
|
|
78
|
+
case 246: // NewDecimal
|
|
79
|
+
types[columnIndex] = "number"; break;
|
|
80
|
+
|
|
81
|
+
case 7: // Timestamp
|
|
82
|
+
case 10: // Date
|
|
83
|
+
case 12: // DateTime
|
|
84
|
+
case 14: // Newdate
|
|
85
|
+
types[columnIndex] = "datetime"; break;
|
|
86
|
+
|
|
87
|
+
case 11: // Time
|
|
88
|
+
types[columnIndex] = "time"; break;
|
|
89
|
+
|
|
90
|
+
case 15: // VarString
|
|
91
|
+
case 247: // Enum
|
|
92
|
+
case 248: // Set
|
|
93
|
+
case 249: // TinyBlob
|
|
94
|
+
case 250: // MediumBlob
|
|
95
|
+
case 251: // LongBlob
|
|
96
|
+
case 252: // Blob
|
|
97
|
+
case 253: // VarChar
|
|
98
|
+
case 254: // String
|
|
99
|
+
case 255: // Geometry
|
|
100
|
+
case 600: // Binary
|
|
101
|
+
case 601: // VarBinary
|
|
102
|
+
case 749: // TinyText
|
|
103
|
+
case 750: // MediumText
|
|
104
|
+
case 751: // LongText
|
|
105
|
+
case 752: // Text
|
|
106
|
+
case 800: // Guid
|
|
107
|
+
|
|
108
|
+
default:
|
|
109
|
+
types[columnIndex] = "string"; break;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (recordset.length > 0 && Array.isArray(recordset[0])) recordset = recordset[0];
|
|
114
|
+
for (var recordIndex in recordset) {
|
|
115
|
+
var row = [];
|
|
116
|
+
for (var columnName in recordset[recordIndex]) {
|
|
117
|
+
var columnIndex = columns.indexOf(columnName);
|
|
118
|
+
if (recordset[recordIndex][columnName] instanceof Uint8Array ||
|
|
119
|
+
recordset[recordIndex][columnName] instanceof Buffer) {
|
|
120
|
+
types[columnIndex] = "array";
|
|
121
|
+
recordset[recordIndex][columnName] = Buffer.from(recordset[recordIndex][columnName]).toString('base64');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (recordset[recordIndex][columnName] != null && typeof recordset[recordIndex][columnName].toISOString === "function") {
|
|
125
|
+
var dateTime = new Date(recordset[recordIndex][columnName].getTime() - (recordset[recordIndex][columnName].getTimezoneOffset() * 60000)).toISOString();
|
|
126
|
+
recordset[recordIndex][columnName] = dateTime.replace("Z", "");
|
|
127
|
+
types[columnIndex] = "datetime";
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
row[columnIndex] = recordset[recordIndex][columnName];
|
|
131
|
+
}
|
|
132
|
+
rows.push(row);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
end({ success: true, columns: columns, rows: rows, types: types });
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
var getConnectionStringInfo = function (connectionString) {
|
|
139
|
+
var info = { host: "localhost", port: "3306", charset: "utf8" };
|
|
140
|
+
|
|
141
|
+
for (var propertyIndex in connectionString.split(";")) {
|
|
142
|
+
var property = connectionString.split(";")[propertyIndex];
|
|
143
|
+
if (property) {
|
|
144
|
+
var match = property.split("=");
|
|
145
|
+
if (match && match.length >= 2) {
|
|
146
|
+
match[0] = match[0].trim().toLowerCase();
|
|
147
|
+
match[1] = match[1].trim();
|
|
148
|
+
|
|
149
|
+
switch (match[0]) {
|
|
150
|
+
case "server":
|
|
151
|
+
case "host":
|
|
152
|
+
case "location":
|
|
153
|
+
info["host"] = match[1];
|
|
154
|
+
break;
|
|
155
|
+
|
|
156
|
+
case "port":
|
|
157
|
+
info["port"] = match[1];
|
|
158
|
+
break;
|
|
159
|
+
|
|
160
|
+
case "database":
|
|
161
|
+
case "data source":
|
|
162
|
+
info["database"] = match[1];
|
|
163
|
+
break;
|
|
164
|
+
|
|
165
|
+
case "uid":
|
|
166
|
+
case "user":
|
|
167
|
+
case "username":
|
|
168
|
+
case "userid":
|
|
169
|
+
case "user id":
|
|
170
|
+
info["userId"] = match[1];
|
|
171
|
+
break;
|
|
172
|
+
|
|
173
|
+
case "pwd":
|
|
174
|
+
case "password":
|
|
175
|
+
info["password"] = match[1];
|
|
176
|
+
break;
|
|
177
|
+
|
|
178
|
+
case "charset":
|
|
179
|
+
info["charset"] = match[1];
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return info;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
var mysql = require('mysql');
|
|
190
|
+
command.connectionStringInfo = getConnectionStringInfo(command.connectionString);
|
|
191
|
+
|
|
192
|
+
var connection = mysql.createConnection({
|
|
193
|
+
host: command.connectionStringInfo.host,
|
|
194
|
+
user: command.connectionStringInfo.userId,
|
|
195
|
+
password: command.connectionStringInfo.password,
|
|
196
|
+
port: command.connectionStringInfo.port,
|
|
197
|
+
charset: command.connectionStringInfo.charset,
|
|
198
|
+
database: command.connectionStringInfo.database
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
connect();
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
}
|
|
205
|
+
catch (e) {
|
|
206
|
+
onError(e.stack);
|
|
207
|
+
}
|
|
202
208
|
}
|