@naturalcycles/mysql-lib 4.5.0 → 4.6.0
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/dist/mysql.db.d.ts +2 -2
- package/dist/mysqlKeyValueDB.d.ts +1 -4
- package/dist/query.util.js +5 -3
- package/package.json +2 -2
- package/src/query.util.ts +5 -3
package/dist/mysql.db.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CommonDB, CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions, CommonDBSupport, RunQueryResult } from '@naturalcycles/db-lib';
|
|
2
|
-
import { BaseCommonDB,
|
|
2
|
+
import { BaseCommonDB, DBQuery } from '@naturalcycles/db-lib';
|
|
3
3
|
import type { JsonSchemaObject, JsonSchemaRootObject } from '@naturalcycles/js-lib/json-schema';
|
|
4
4
|
import type { CommonLogger } from '@naturalcycles/js-lib/log';
|
|
5
5
|
import type { ObjectWithId } from '@naturalcycles/js-lib/types';
|
|
@@ -27,7 +27,7 @@ export interface MysqlDBCfg extends PoolConfig {
|
|
|
27
27
|
logger?: CommonLogger;
|
|
28
28
|
}
|
|
29
29
|
export declare class MysqlDB extends BaseCommonDB implements CommonDB {
|
|
30
|
-
dbType:
|
|
30
|
+
dbType: any;
|
|
31
31
|
support: CommonDBSupport;
|
|
32
32
|
constructor(cfg?: MysqlDBCfg);
|
|
33
33
|
cfg: MysqlDBCfg & {
|
|
@@ -7,10 +7,7 @@ export declare class MySQLKeyValueDB implements CommonKeyValueDB {
|
|
|
7
7
|
cfg: MysqlDBCfg;
|
|
8
8
|
constructor(cfg: MysqlDBCfg);
|
|
9
9
|
db: MysqlDB;
|
|
10
|
-
support:
|
|
11
|
-
increment: boolean;
|
|
12
|
-
count?: boolean;
|
|
13
|
-
};
|
|
10
|
+
support: any;
|
|
14
11
|
ping(): Promise<void>;
|
|
15
12
|
close(): Promise<void>;
|
|
16
13
|
createTable(table: string, opt?: CommonDBCreateOptions): Promise<void>;
|
package/dist/query.util.js
CHANGED
|
@@ -43,7 +43,9 @@ export function insertSQL(table, rows, verb = 'INSERT', logger = console) {
|
|
|
43
43
|
// VALUES (value1, value2, value3, ...);
|
|
44
44
|
// eslint-disable-next-line unicorn/no-array-reduce
|
|
45
45
|
const fieldSet = rows.reduce((set, row) => {
|
|
46
|
-
|
|
46
|
+
for (const field of Object.keys(row)) {
|
|
47
|
+
set.add(field);
|
|
48
|
+
}
|
|
47
49
|
return set;
|
|
48
50
|
}, new Set());
|
|
49
51
|
const fields = [...fieldSet];
|
|
@@ -62,7 +64,7 @@ export function insertSQL(table, rows, verb = 'INSERT', logger = console) {
|
|
|
62
64
|
return [full];
|
|
63
65
|
const sqls = [];
|
|
64
66
|
let sql;
|
|
65
|
-
|
|
67
|
+
for (const vrow of valueRows) {
|
|
66
68
|
if (!sql) {
|
|
67
69
|
sql = start + vrow;
|
|
68
70
|
}
|
|
@@ -75,7 +77,7 @@ export function insertSQL(table, rows, verb = 'INSERT', logger = console) {
|
|
|
75
77
|
sql += ',\n ' + vrow; // add
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
|
-
}
|
|
80
|
+
}
|
|
79
81
|
if (sql) {
|
|
80
82
|
sqls.push(sql); // last one
|
|
81
83
|
}
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"@types/node": "^24",
|
|
14
14
|
"dotenv": "^17",
|
|
15
|
-
"@naturalcycles/dev-lib": "
|
|
15
|
+
"@naturalcycles/dev-lib": "18.4.2"
|
|
16
16
|
},
|
|
17
17
|
"exports": {
|
|
18
18
|
".": "./dist/index.js"
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=22.12.0"
|
|
40
40
|
},
|
|
41
|
-
"version": "4.
|
|
41
|
+
"version": "4.6.0",
|
|
42
42
|
"description": "MySQL client implementing CommonDB interface",
|
|
43
43
|
"keywords": [
|
|
44
44
|
"mysql",
|
package/src/query.util.ts
CHANGED
|
@@ -62,7 +62,9 @@ export function insertSQL(
|
|
|
62
62
|
|
|
63
63
|
// eslint-disable-next-line unicorn/no-array-reduce
|
|
64
64
|
const fieldSet = rows.reduce((set: Set<string>, row) => {
|
|
65
|
-
|
|
65
|
+
for (const field of Object.keys(row)) {
|
|
66
|
+
set.add(field)
|
|
67
|
+
}
|
|
66
68
|
return set
|
|
67
69
|
}, new Set<string>())
|
|
68
70
|
const fields = [...fieldSet]
|
|
@@ -86,7 +88,7 @@ export function insertSQL(
|
|
|
86
88
|
const sqls: string[] = []
|
|
87
89
|
let sql: string | undefined
|
|
88
90
|
|
|
89
|
-
|
|
91
|
+
for (const vrow of valueRows) {
|
|
90
92
|
if (!sql) {
|
|
91
93
|
sql = start + vrow
|
|
92
94
|
} else {
|
|
@@ -97,7 +99,7 @@ export function insertSQL(
|
|
|
97
99
|
sql += ',\n ' + vrow // add
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
|
-
}
|
|
102
|
+
}
|
|
101
103
|
|
|
102
104
|
if (sql) {
|
|
103
105
|
sqls.push(sql) // last one
|