mm_sqlite 1.2.5 → 1.2.7
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/index.js +6 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -281,7 +281,7 @@ SQLite.prototype.getConn = async function (timeout) {
|
|
|
281
281
|
* @returns {Promise<object>}
|
|
282
282
|
* @throws {TypeError} 当sql参数无效时
|
|
283
283
|
*/
|
|
284
|
-
SQLite.prototype.run = async function (sql, params, timeout) {
|
|
284
|
+
SQLite.prototype.run = async function (sql, params = [], timeout = 30000) {
|
|
285
285
|
// 参数校验
|
|
286
286
|
if (typeof sql !== 'string' || sql.trim() === '') {
|
|
287
287
|
throw new TypeError('sql must be non-empty string');
|
|
@@ -311,7 +311,8 @@ SQLite.prototype.run = async function (sql, params, timeout) {
|
|
|
311
311
|
code: error.errno,
|
|
312
312
|
message: error.message
|
|
313
313
|
};
|
|
314
|
-
|
|
314
|
+
// 不抛出错误,保持与MySQL一致的错误处理行为
|
|
315
|
+
resolve([]);
|
|
315
316
|
} else {
|
|
316
317
|
// 保持与MySQL兼容的返回值格式,始终返回数组
|
|
317
318
|
resolve(rows);
|
|
@@ -345,7 +346,7 @@ SQLite.prototype.run = async function (sql, params, timeout) {
|
|
|
345
346
|
if (err.code && (err.code === 'ECONNRESET' || err.code === 'ETIMEDOUT')) {
|
|
346
347
|
this._handleConnectionError(err);
|
|
347
348
|
}
|
|
348
|
-
//
|
|
349
|
+
// 返回空数组,保持与MySQL一致的错误处理行为
|
|
349
350
|
return [];
|
|
350
351
|
}
|
|
351
352
|
};
|
|
@@ -387,7 +388,7 @@ SQLite.prototype.exec = async function (sql, params, timeout) {
|
|
|
387
388
|
code: error.errno,
|
|
388
389
|
message: error.message
|
|
389
390
|
};
|
|
390
|
-
|
|
391
|
+
// 不抛出错误,保持与MySQL一致的错误处理行为
|
|
391
392
|
resolve(0);
|
|
392
393
|
} else {
|
|
393
394
|
// 保持与MySQL兼容的返回值格式
|
|
@@ -422,7 +423,7 @@ SQLite.prototype.exec = async function (sql, params, timeout) {
|
|
|
422
423
|
if (err.code && (err.code === 'ECONNRESET' || err.code === 'ETIMEDOUT')) {
|
|
423
424
|
this._handleConnectionError(err);
|
|
424
425
|
}
|
|
425
|
-
//
|
|
426
|
+
// 返回0,保持与MySQL一致的错误处理行为
|
|
426
427
|
return 0;
|
|
427
428
|
}
|
|
428
429
|
};
|