@superhero/db 0.5.0 → 0.5.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/adapter/mysql2/index.js +1 -1
- package/index.js +9 -4
- package/package.json +1 -1
package/adapter/mysql2/index.js
CHANGED
|
@@ -12,7 +12,7 @@ class AdapterMySql2
|
|
|
12
12
|
const resolve = (accept, reject, i = 0) =>
|
|
13
13
|
this.pool.query(query, ctx, (error, response) =>
|
|
14
14
|
error
|
|
15
|
-
?
|
|
15
|
+
? ['ETIMEDOUT', 'ECONNREFUSED', 'ECONNRESET'].includes(error.code) && i < 3
|
|
16
16
|
? resolve(accept, reject, ++i)
|
|
17
17
|
: reject(error)
|
|
18
18
|
: accept(response))
|
package/index.js
CHANGED
|
@@ -21,11 +21,16 @@ class Db
|
|
|
21
21
|
|
|
22
22
|
async query(file, ...ctx)
|
|
23
23
|
{
|
|
24
|
-
|
|
25
|
-
query = await this.getQuery(file),
|
|
26
|
-
response = await this.adaptor.query(query, ...ctx)
|
|
24
|
+
let query = await this.getQuery(file)
|
|
27
25
|
|
|
28
|
-
|
|
26
|
+
for(let noEscapeReplace = query.indexOf('?%s');
|
|
27
|
+
noEscapeReplace > -1;
|
|
28
|
+
noEscapeReplace = query.indexOf('?%s'))
|
|
29
|
+
{
|
|
30
|
+
query = query.replace('?%s', ctx.shift())
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return await this.adaptor.query(query, ...ctx)
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
async formatQuery(file, formatCtx, sqlCtx)
|