badmfck-api-server 2.3.7 → 2.3.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -83,7 +83,7 @@ async function Initializer(services) {
83
83
  exports.Initializer = Initializer;
84
84
  class APIService extends BaseService_1.BaseService {
85
85
  static nextLogID = 0;
86
- version = "2.3.7";
86
+ version = "2.3.9";
87
87
  options;
88
88
  monitor;
89
89
  monitorIndexFile;
@@ -156,12 +156,11 @@ class MysqlService extends BaseService_1.BaseService {
156
156
  console.log("Begin transaction with id ", tid);
157
157
  try {
158
158
  await conn.query("START TRANSACTION");
159
- const res = await conn.query("SET autocommit=0");
160
159
  if (this.debug)
161
- console.log("Transaction started, SET autocommit=0 ", tid, res);
160
+ console.log("Transaction started");
162
161
  }
163
162
  catch (e) {
164
- this.rollbackTransaction({ id: tid, conn: conn, timestamp: Date.now(), queries: [{ sql: "SET autocommit=0", status: "error" }] });
163
+ this.rollbackTransaction({ id: tid, conn: conn, timestamp: Date.now(), queries: [{ sql: "START TRANSACTION", status: "error" }] });
165
164
  return this.createMysqlQueryError(e);
166
165
  }
167
166
  this.transactions.push({
@@ -256,7 +255,7 @@ class MysqlService extends BaseService_1.BaseService {
256
255
  };
257
256
  let income = [];
258
257
  try {
259
- await conn.query("START TRANSACTION; SET autocommit=0");
258
+ await conn.query("START TRANSACTION");
260
259
  }
261
260
  catch (e) {
262
261
  const err = this.createMysqlQueryError(e);
@@ -288,7 +287,7 @@ class MysqlService extends BaseService_1.BaseService {
288
287
  }
289
288
  async commit(trx) {
290
289
  try {
291
- await trx.conn.query("COMMIT");
290
+ await trx.conn.commit();
292
291
  trx.conn.removeAllListeners();
293
292
  trx.conn.release();
294
293
  }
@@ -302,7 +301,8 @@ class MysqlService extends BaseService_1.BaseService {
302
301
  let err = null;
303
302
  try {
304
303
  console.log("Rollback started", trx.conn);
305
- await trx.conn.query("ROLLBACK");
304
+ await trx.conn.rollback();
305
+ await trx.conn.commit();
306
306
  trx.conn.removeAllListeners();
307
307
  trx.conn.release();
308
308
  if (!donNotRemove)
@@ -457,8 +457,18 @@ class MysqlService extends BaseService_1.BaseService {
457
457
  return obj;
458
458
  const fields = [];
459
459
  for (let i in obj) {
460
- if (typeof obj[i] === "object") {
461
- const mo = obj[i];
460
+ if (obj[i] && typeof obj[i] === "object") {
461
+ let mo = obj[i];
462
+ if (!mo) {
463
+ mo = {
464
+ name: i,
465
+ value: null,
466
+ system: false,
467
+ ignoreInInsert: false,
468
+ ignoreInUpdate: false,
469
+ useInReplace: false
470
+ };
471
+ }
462
472
  fields.push({
463
473
  name: i,
464
474
  value: mo.value,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "2.3.7",
3
+ "version": "2.3.9",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",