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.
Files changed (2) hide show
  1. package/index.js +6 -5
  2. 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
- reject(error);
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
- reject(error);
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_sqlite",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "高性能SQLite数据库操作模块,提供与mm_mysql完全兼容的API接口,支持异步操作、事务处理和批量操作",
5
5
  "main": "index.js",
6
6
  "scripts": {