@openfn/language-mssql 5.2.2 → 6.0.0
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/dist/index.cjs +14 -13
- package/dist/index.js +14 -13
- package/package.json +1 -1
- package/types/Adaptor.d.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -35,7 +35,6 @@ __export(src_exports, {
|
|
|
35
35
|
findValue: () => findValue,
|
|
36
36
|
fn: () => import_language_common2.fn,
|
|
37
37
|
fnIf: () => import_language_common2.fnIf,
|
|
38
|
-
http: () => import_language_common2.http,
|
|
39
38
|
insert: () => insert,
|
|
40
39
|
insertMany: () => insertMany,
|
|
41
40
|
insertTable: () => insertTable,
|
|
@@ -69,7 +68,6 @@ __export(Adaptor_exports, {
|
|
|
69
68
|
findValue: () => findValue,
|
|
70
69
|
fn: () => import_language_common2.fn,
|
|
71
70
|
fnIf: () => import_language_common2.fnIf,
|
|
72
|
-
http: () => import_language_common2.http,
|
|
73
71
|
insert: () => insert,
|
|
74
72
|
insertMany: () => insertMany,
|
|
75
73
|
insertTable: () => insertTable,
|
|
@@ -201,15 +199,19 @@ function queryHandler(state, query, callback, options) {
|
|
|
201
199
|
return state;
|
|
202
200
|
}
|
|
203
201
|
}
|
|
204
|
-
const
|
|
202
|
+
const rows = [];
|
|
203
|
+
const request = new import_tedious.Request(query, (err) => {
|
|
205
204
|
if (err) {
|
|
206
205
|
console.error(err);
|
|
207
206
|
reject(err);
|
|
208
207
|
} else {
|
|
209
|
-
console.log(`Finished: ${
|
|
208
|
+
console.log(`Finished: ${rows.length} row(s).`);
|
|
210
209
|
resolve(callback(state, rows));
|
|
211
210
|
}
|
|
212
211
|
});
|
|
212
|
+
request.on("row", (columns) => {
|
|
213
|
+
rows.push(columns);
|
|
214
|
+
});
|
|
213
215
|
connection.execSql(request);
|
|
214
216
|
});
|
|
215
217
|
}
|
|
@@ -256,8 +258,7 @@ function findValue(filter) {
|
|
|
256
258
|
return (state) => {
|
|
257
259
|
const { connection } = state;
|
|
258
260
|
const { uuid, relation, where, operator } = filter;
|
|
259
|
-
const [whereData] = (0, import_util.expandReferences)(state, where);
|
|
260
|
-
const [operatorData] = (0, import_util.expandReferences)(state, operator);
|
|
261
|
+
const [whereData, operatorData] = (0, import_util.expandReferences)(state, where, operator);
|
|
261
262
|
let conditionsArray = [];
|
|
262
263
|
for (let key in whereData) {
|
|
263
264
|
const escapedValue = escape(whereData[key]);
|
|
@@ -269,24 +270,25 @@ function findValue(filter) {
|
|
|
269
270
|
try {
|
|
270
271
|
const body = `select ${uuid} from ${relation} ${condition}`;
|
|
271
272
|
console.log("Preparing to execute sql statement");
|
|
272
|
-
let returnValue = null;
|
|
273
273
|
return new Promise((resolve, reject) => {
|
|
274
274
|
console.log(`Executing query: ${body}`);
|
|
275
|
-
const
|
|
275
|
+
const rows = [];
|
|
276
|
+
const request = new import_tedious.Request(body, (err) => {
|
|
276
277
|
if (err) {
|
|
277
278
|
console.error(err.message);
|
|
278
279
|
reject(err);
|
|
279
280
|
} else {
|
|
280
281
|
if (rows.length > 0) {
|
|
281
|
-
|
|
282
|
-
}
|
|
283
|
-
if (returnValue === null) {
|
|
282
|
+
resolve(rows[0][0].value);
|
|
283
|
+
} else {
|
|
284
284
|
console.log("No value found");
|
|
285
285
|
resolve(void 0);
|
|
286
286
|
}
|
|
287
|
-
resolve(returnValue);
|
|
288
287
|
}
|
|
289
288
|
});
|
|
289
|
+
request.on("row", (columns) => {
|
|
290
|
+
rows.push(columns);
|
|
291
|
+
});
|
|
290
292
|
connection.execSql(request);
|
|
291
293
|
});
|
|
292
294
|
} catch (e) {
|
|
@@ -586,7 +588,6 @@ var src_default = Adaptor_exports;
|
|
|
586
588
|
findValue,
|
|
587
589
|
fn,
|
|
588
590
|
fnIf,
|
|
589
|
-
http,
|
|
590
591
|
insert,
|
|
591
592
|
insertMany,
|
|
592
593
|
insertTable,
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,6 @@ __export(Adaptor_exports, {
|
|
|
22
22
|
findValue: () => findValue,
|
|
23
23
|
fn: () => fn,
|
|
24
24
|
fnIf: () => fnIf,
|
|
25
|
-
http: () => http,
|
|
26
25
|
insert: () => insert,
|
|
27
26
|
insertMany: () => insertMany,
|
|
28
27
|
insertTable: () => insertTable,
|
|
@@ -65,7 +64,6 @@ import {
|
|
|
65
64
|
fields,
|
|
66
65
|
fn,
|
|
67
66
|
fnIf,
|
|
68
|
-
http,
|
|
69
67
|
lastReferenceValue,
|
|
70
68
|
cursor,
|
|
71
69
|
merge,
|
|
@@ -171,15 +169,19 @@ function queryHandler(state, query, callback, options) {
|
|
|
171
169
|
return state;
|
|
172
170
|
}
|
|
173
171
|
}
|
|
174
|
-
const
|
|
172
|
+
const rows = [];
|
|
173
|
+
const request = new Request(query, (err) => {
|
|
175
174
|
if (err) {
|
|
176
175
|
console.error(err);
|
|
177
176
|
reject(err);
|
|
178
177
|
} else {
|
|
179
|
-
console.log(`Finished: ${
|
|
178
|
+
console.log(`Finished: ${rows.length} row(s).`);
|
|
180
179
|
resolve(callback(state, rows));
|
|
181
180
|
}
|
|
182
181
|
});
|
|
182
|
+
request.on("row", (columns) => {
|
|
183
|
+
rows.push(columns);
|
|
184
|
+
});
|
|
183
185
|
connection.execSql(request);
|
|
184
186
|
});
|
|
185
187
|
}
|
|
@@ -226,8 +228,7 @@ function findValue(filter) {
|
|
|
226
228
|
return (state) => {
|
|
227
229
|
const { connection } = state;
|
|
228
230
|
const { uuid, relation, where, operator } = filter;
|
|
229
|
-
const [whereData] = expandReferences(state, where);
|
|
230
|
-
const [operatorData] = expandReferences(state, operator);
|
|
231
|
+
const [whereData, operatorData] = expandReferences(state, where, operator);
|
|
231
232
|
let conditionsArray = [];
|
|
232
233
|
for (let key in whereData) {
|
|
233
234
|
const escapedValue = escape(whereData[key]);
|
|
@@ -239,24 +240,25 @@ function findValue(filter) {
|
|
|
239
240
|
try {
|
|
240
241
|
const body = `select ${uuid} from ${relation} ${condition}`;
|
|
241
242
|
console.log("Preparing to execute sql statement");
|
|
242
|
-
let returnValue = null;
|
|
243
243
|
return new Promise((resolve, reject) => {
|
|
244
244
|
console.log(`Executing query: ${body}`);
|
|
245
|
-
const
|
|
245
|
+
const rows = [];
|
|
246
|
+
const request = new Request(body, (err) => {
|
|
246
247
|
if (err) {
|
|
247
248
|
console.error(err.message);
|
|
248
249
|
reject(err);
|
|
249
250
|
} else {
|
|
250
251
|
if (rows.length > 0) {
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
if (returnValue === null) {
|
|
252
|
+
resolve(rows[0][0].value);
|
|
253
|
+
} else {
|
|
254
254
|
console.log("No value found");
|
|
255
255
|
resolve(void 0);
|
|
256
256
|
}
|
|
257
|
-
resolve(returnValue);
|
|
258
257
|
}
|
|
259
258
|
});
|
|
259
|
+
request.on("row", (columns) => {
|
|
260
|
+
rows.push(columns);
|
|
261
|
+
});
|
|
260
262
|
connection.execSql(request);
|
|
261
263
|
});
|
|
262
264
|
} catch (e) {
|
|
@@ -556,7 +558,6 @@ export {
|
|
|
556
558
|
findValue,
|
|
557
559
|
fn,
|
|
558
560
|
fnIf,
|
|
559
|
-
http,
|
|
560
561
|
insert,
|
|
561
562
|
insertMany,
|
|
562
563
|
insertTable,
|
package/package.json
CHANGED
package/types/Adaptor.d.ts
CHANGED
|
@@ -170,4 +170,4 @@ export function insertTable(tableName: string, columns: any[], options: object):
|
|
|
170
170
|
* @returns {Operation}
|
|
171
171
|
*/
|
|
172
172
|
export function modifyTable(tableName: string, columns: any[], options: object): Operation;
|
|
173
|
-
export { alterState, combine, dataPath, dataValue, dateFns, each, field, fields, fn, fnIf,
|
|
173
|
+
export { alterState, combine, dataPath, dataValue, dateFns, each, field, fields, fn, fnIf, lastReferenceValue, cursor, merge, sourceValue, as } from "@openfn/language-common";
|