badmfck-api-server 2.9.1 → 2.9.3

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.
@@ -89,7 +89,7 @@ async function Initializer(services) {
89
89
  exports.Initializer = Initializer;
90
90
  class APIService extends BaseService_1.BaseService {
91
91
  static nextLogID = 0;
92
- version = "2.9.0";
92
+ version = "2.9.3";
93
93
  options;
94
94
  monitor = null;
95
95
  monitorIndexFile;
@@ -1,7 +1,7 @@
1
1
  import { Req } from "badmfck-signal";
2
2
  import { BaseService } from "./BaseService";
3
3
  import { IDBAdapter } from "./db/IDBAdapter";
4
- export interface IDBQueryField extends Record<string, string | number | boolean | null | undefined | {
4
+ export interface IDBQueryField {
5
5
  name?: string | null;
6
6
  value: string | number | boolean | null | undefined;
7
7
  system?: boolean;
@@ -9,12 +9,13 @@ export interface IDBQueryField extends Record<string, string | number | boolean
9
9
  ignoreInUpdate?: boolean;
10
10
  useInReplace?: boolean;
11
11
  __parsedValue?: string | number | boolean | null | undefined;
12
- }> {
13
12
  }
14
13
  export interface IDBQuery {
15
14
  dbid?: string;
16
15
  query: string;
17
- fields?: IDBQueryField;
16
+ fields?: {
17
+ [key: string]: IDBQueryField | null | string | number | boolean;
18
+ };
18
19
  throwable?: boolean;
19
20
  transactionID?: number;
20
21
  calculateCount?: boolean;
@@ -270,13 +270,16 @@ class MysqlAdapter {
270
270
  if (fields) {
271
271
  for (let i in fields) {
272
272
  const name = i;
273
- const value = fields[i];
274
- if (typeof value === "string" || typeof value === "number" || typeof value === "boolean")
275
- fields[i] = { value: value, system: false };
276
- if (value === undefined)
273
+ let queryField = fields[i];
274
+ if (queryField === undefined)
277
275
  continue;
278
- if (value === null)
279
- fields[i] = { value: null, system: true };
276
+ if (typeof queryField === "string" || typeof queryField === "number" || typeof queryField === "boolean")
277
+ queryField = { value: queryField, system: false };
278
+ if (queryField === null)
279
+ queryField = { value: null, system: true };
280
+ if (!queryField.name)
281
+ queryField.name = name.replaceAll("`", '').replaceAll('\"', "").replaceAll('\'', "");
282
+ fields[i] = queryField;
280
283
  const parsed = MysqlAdapter.prepareQueryFieldValue(fields[i]);
281
284
  query = query.replaceAll("@" + name, parsed + "");
282
285
  }
@@ -292,11 +295,8 @@ class MysqlAdapter {
292
295
  let f = fields[i];
293
296
  if (f.ignoreInInsert)
294
297
  continue;
295
- let name = f.name;
296
- if (!name)
297
- name = i.replaceAll("`", '').replaceAll('\"', "").replaceAll('\'', "");
298
- insertFieldNames.push('`' + (name + "").replaceAll("`", '').replaceAll('\"', "").replaceAll('\'', "") + '`');
299
- insertFieldValues.push(f._parsedValue);
298
+ insertFieldNames.push('`' + f.name + '`');
299
+ insertFieldValues.push(f.__parsedValue);
300
300
  }
301
301
  query = query
302
302
  .replaceAll('@fields', insertFieldNames.join(","))
@@ -309,11 +309,8 @@ class MysqlAdapter {
309
309
  let f = fields[i];
310
310
  if (f.ignoreInInsert)
311
311
  continue;
312
- let name = f.name;
313
- if (!name)
314
- name = i.replaceAll("`", '').replaceAll('\"', "").replaceAll('\'', "");
315
- oninsertNames.push(name);
316
- oninsertValues.push(f._parsedValue);
312
+ oninsertNames.push(f.name);
313
+ oninsertValues.push(f.__parsedValue);
317
314
  }
318
315
  query = query.replaceAll("@insert", `(${oninsertNames.join(",")}) VALUES (${oninsertValues.join(",")})`);
319
316
  }
@@ -323,10 +320,7 @@ class MysqlAdapter {
323
320
  let f = fields[i];
324
321
  if (f.ignoreInUpdate)
325
322
  continue;
326
- let name = f.name;
327
- if (!name)
328
- name = i.replaceAll("`", '').replaceAll('\"', "").replaceAll('\'', "");
329
- onUpdate.push('`' + (name + "") + '` = ' + f._parsedValue);
323
+ onUpdate.push('`' + f.name + '` = ' + f.__parsedValue);
330
324
  }
331
325
  query = query.replaceAll("@onupdate", onUpdate.join(" , "));
332
326
  }
@@ -336,10 +330,7 @@ class MysqlAdapter {
336
330
  let f = fields[i];
337
331
  if (!f.useInReplace)
338
332
  continue;
339
- let name = f.name;
340
- if (!name)
341
- name = i.replaceAll("`", '').replaceAll('\"', "").replaceAll('\'', "");
342
- onDuplicate.push('`' + (name + "") + f._parsedValue);
333
+ onDuplicate.push('`' + f.name + f.__parsedValue);
343
334
  }
344
335
  query = query.replaceAll("@onduplicate", onDuplicate.join(" , "));
345
336
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "2.9.1",
3
+ "version": "2.9.3",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",