@opengis/fastify-table 1.2.65 → 1.2.66
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/package.json
CHANGED
|
@@ -20,13 +20,16 @@ async function init(client) {
|
|
|
20
20
|
from pg_class where relkind in ('r','v')`);
|
|
21
21
|
const relkinds = rows.reduce((acc, curr) => Object.assign(acc, { [curr.tname]: curr.relkind }), {});
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
async function query(q, args = []) {
|
|
23
|
+
async function query(q, args = [], isstream) {
|
|
26
24
|
try {
|
|
25
|
+
if (isstream) {
|
|
26
|
+
await client.query('set statement_timeout to 100000000');
|
|
27
|
+
}
|
|
27
28
|
const data = await client.query(q, args);
|
|
29
|
+
await client.query('set statement_timeout to 0');
|
|
28
30
|
return data;
|
|
29
31
|
} catch (err) {
|
|
32
|
+
await client.query('set statement_timeout to 0');
|
|
30
33
|
if (err.message === 'canceling statement due to statement timeout') {
|
|
31
34
|
logger.file('timeout/query', { q, stack: err.stack });
|
|
32
35
|
return { rows: [], timeout: true };
|
|
@@ -35,6 +38,12 @@ async function init(client) {
|
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
40
|
|
|
41
|
+
async function querySafe(q, param = {}) {
|
|
42
|
+
const { args, isstream } = param;
|
|
43
|
+
const data = await query(q, args, isstream);
|
|
44
|
+
return data;
|
|
45
|
+
}
|
|
46
|
+
|
|
38
47
|
async function one(q, param = {}) {
|
|
39
48
|
const data = await query(q, Array.isArray(param) ? param : param.args || []);
|
|
40
49
|
const result = ((Array.isArray(data) ? data.pop() : data)?.rows || [])[0] || {};
|
|
@@ -88,7 +97,7 @@ async function init(client) {
|
|
|
88
97
|
}
|
|
89
98
|
|
|
90
99
|
Object.assign(client, {
|
|
91
|
-
one, pgType, pk, tlist, relkinds, queryCache, queryNotice,
|
|
100
|
+
one, pgType, pk, tlist, relkinds, queryCache, queryNotice, querySafe,
|
|
92
101
|
});
|
|
93
102
|
}
|
|
94
103
|
|