@l-v-yonsama/multi-platform-database-drivers 0.1.13 → 0.1.16
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/README.md +109 -0
- package/built/src/db/DBError.d.ts +1 -1
- package/built/src/db/DBError.js +5 -1
- package/built/src/db/DBError.js.map +1 -1
- package/built/src/db/drivers/AwsS3Driver.d.ts +3 -4
- package/built/src/db/drivers/AwsS3Driver.js +130 -105
- package/built/src/db/drivers/AwsS3Driver.js.map +1 -1
- package/built/src/db/drivers/BaseDriver.d.ts +3 -4
- package/built/src/db/drivers/BaseDriver.js +75 -65
- package/built/src/db/drivers/BaseDriver.js.map +1 -1
- package/built/src/db/drivers/MySQLDriver.d.ts +3 -4
- package/built/src/db/drivers/MySQLDriver.js +199 -179
- package/built/src/db/drivers/MySQLDriver.js.map +1 -1
- package/built/src/db/drivers/PostgresDriver.d.ts +3 -4
- package/built/src/db/drivers/PostgresDriver.js +184 -162
- package/built/src/db/drivers/PostgresDriver.js.map +1 -1
- package/built/src/db/drivers/RedisDriver.d.ts +3 -4
- package/built/src/db/drivers/RedisDriver.js +180 -160
- package/built/src/db/drivers/RedisDriver.js.map +1 -1
- package/built/src/db/drivers/index.js +8 -5
- package/built/src/db/drivers/index.js.map +1 -1
- package/built/src/db/index.js +6 -3
- package/built/src/db/index.js.map +1 -1
- package/built/src/db/resource/DbResource.d.ts +1 -5
- package/built/src/db/resource/DbResource.js +54 -43
- package/built/src/db/resource/DbResource.js.map +1 -1
- package/built/src/db/resource/MultipleResultSetDataHolder.d.ts +2 -2
- package/built/src/db/resource/MultipleResultSetDataHolder.js +10 -5
- package/built/src/db/resource/MultipleResultSetDataHolder.js.map +1 -1
- package/built/src/db/resource/ResourceHelper.js +5 -1
- package/built/src/db/resource/ResourceHelper.js.map +1 -1
- package/built/src/db/resource/ResultSetDataHolder.d.ts +2 -2
- package/built/src/db/resource/ResultSetDataHolder.js +43 -33
- package/built/src/db/resource/ResultSetDataHolder.js.map +1 -1
- package/built/src/db/resource/index.js +8 -5
- package/built/src/db/resource/index.js.map +1 -1
- package/built/src/db/resource/types/DBType.js +6 -3
- package/built/src/db/resource/types/DBType.js.map +1 -1
- package/built/src/db/resource/types/GeneralColumnType.js +8 -5
- package/built/src/db/resource/types/GeneralColumnType.js.map +1 -1
- package/built/src/db/resource/types/MySQLColumnType.js +10 -7
- package/built/src/db/resource/types/MySQLColumnType.js.map +1 -1
- package/built/src/db/resource/types/ODBCVendorType.js +5 -2
- package/built/src/db/resource/types/ODBCVendorType.js.map +1 -1
- package/built/src/db/resource/types/PostgresColumnType.js +9 -6
- package/built/src/db/resource/types/PostgresColumnType.js.map +1 -1
- package/built/src/db/resource/types/RedisKeyType.js +8 -5
- package/built/src/db/resource/types/RedisKeyType.js.map +1 -1
- package/built/src/db/resource/types/ResourceType.js +5 -2
- package/built/src/db/resource/types/ResourceType.js.map +1 -1
- package/built/src/db/resource/types/index.js +10 -7
- package/built/src/db/resource/types/index.js.map +1 -1
- package/built/src/index.js +6 -3
- package/built/src/index.js.map +1 -1
- package/built/src/service/DBAccessService.d.ts +1 -2
- package/built/src/service/DBAccessService.js +271 -246
- package/built/src/service/DBAccessService.js.map +1 -1
- package/built/src/service/DBDriverResolver.d.ts +1 -2
- package/built/src/service/DBDriverResolver.js +31 -32
- package/built/src/service/DBDriverResolver.js.map +1 -1
- package/built/src/service/SQLService.d.ts +1 -1
- package/built/src/service/SQLService.js +8 -3
- package/built/src/service/SQLService.js.map +1 -1
- package/built/src/service/index.js +8 -5
- package/built/src/service/index.js.map +1 -1
- package/built/src/service/request/RedisRequest.d.ts +1 -1
- package/built/src/service/request/RedisRequest.js +5 -2
- package/built/src/service/request/RedisRequest.js.map +1 -1
- package/built/src/service/request/S3Request.js +5 -2
- package/built/src/service/request/S3Request.js.map +1 -1
- package/built/src/service/request/index.d.ts +2 -0
- package/built/src/service/request/index.js +8 -2
- package/built/src/service/request/index.js.map +1 -1
- package/built/src/service/response/GeneralDBResponse.js +2 -1
- package/built/src/service/response/GeneralResponse.js +5 -1
- package/built/src/service/response/GeneralResponse.js.map +1 -1
- package/built/src/service/response/index.d.ts +1 -0
- package/built/src/service/response/index.js +6 -2
- package/built/src/service/response/index.js.map +1 -1
- package/built/src/service/response/result/ConnectionResult.js +3 -0
- package/built/src/service/response/result/ConnectionResult.js.map +1 -0
- package/built/src/service/response/{reply/GeneralReply.d.ts → result/GeneralResult.d.ts} +1 -1
- package/built/src/service/response/result/GeneralResult.js +13 -0
- package/built/src/service/response/result/GeneralResult.js.map +1 -0
- package/built/src/service/response/{reply/ProgressReply.d.ts → result/ProgressResult.d.ts} +2 -2
- package/built/src/service/response/result/ProgressResult.js +14 -0
- package/built/src/service/response/result/ProgressResult.js.map +1 -0
- package/built/src/service/response/result/index.d.ts +3 -0
- package/built/src/service/response/result/index.js +7 -0
- package/built/src/service/response/result/index.js.map +1 -0
- package/built/src/types/DateModifiedType.js +6 -3
- package/built/src/types/DateModifiedType.js.map +1 -1
- package/built/src/types/FileKindType.js +6 -3
- package/built/src/types/FileKindType.js.map +1 -1
- package/built/src/types/index.js +5 -2
- package/built/src/types/index.js.map +1 -1
- package/package.json +3 -4
- package/built/src/service/response/reply/ConnectionResult.js +0 -2
- package/built/src/service/response/reply/ConnectionResult.js.map +0 -1
- package/built/src/service/response/reply/FileExportReply.d.ts +0 -10
- package/built/src/service/response/reply/FileExportReply.js +0 -14
- package/built/src/service/response/reply/FileExportReply.js.map +0 -1
- package/built/src/service/response/reply/FileProcessResult.d.ts +0 -14
- package/built/src/service/response/reply/FileProcessResult.js +0 -25
- package/built/src/service/response/reply/FileProcessResult.js.map +0 -1
- package/built/src/service/response/reply/GeneralReply.js +0 -9
- package/built/src/service/response/reply/GeneralReply.js.map +0 -1
- package/built/src/service/response/reply/OutputReply.d.ts +0 -9
- package/built/src/service/response/reply/OutputReply.js +0 -13
- package/built/src/service/response/reply/OutputReply.js.map +0 -1
- package/built/src/service/response/reply/ProgressReply.js +0 -10
- package/built/src/service/response/reply/ProgressReply.js.map +0 -1
- package/built/src/service/response/reply/types/FileExportType.d.ts +0 -3
- package/built/src/service/response/reply/types/FileExportType.js +0 -6
- package/built/src/service/response/reply/types/FileExportType.js.map +0 -1
- package/built/src/service/response/reply/types/OutputType.d.ts +0 -11
- package/built/src/service/response/reply/types/OutputType.js +0 -13
- package/built/src/service/response/reply/types/OutputType.js.map +0 -1
- package/built/src/service/response/reply/types/ReplyEventType.d.ts +0 -10
- package/built/src/service/response/reply/types/ReplyEventType.js +0 -13
- package/built/src/service/response/reply/types/ReplyEventType.js.map +0 -1
- /package/built/src/service/response/{reply → result}/ConnectionResult.d.ts +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PostgresDriver = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const BaseDriver_1 = require("./BaseDriver");
|
|
6
|
+
const resource_1 = require("../resource");
|
|
7
|
+
const pg_1 = tslib_1.__importDefault(require("pg"));
|
|
8
|
+
const enum_values_1 = require("enum-values");
|
|
9
|
+
class PostgresDriver extends BaseDriver_1.BaseDriver {
|
|
9
10
|
constructor(conRes) {
|
|
10
11
|
super(conRes);
|
|
11
12
|
}
|
|
@@ -13,176 +14,193 @@ export default class PostgresDriver extends BaseDriver {
|
|
|
13
14
|
if (fieldInfo.name.startsWith('c_')) {
|
|
14
15
|
console.log(`★ ${fieldInfo.name.substring(2).toUpperCase()} = ${fieldInfo.dataTypeID}`);
|
|
15
16
|
}
|
|
16
|
-
const name = EnumValues.getNameFromValue(PostgresColumnType, PostgresColumnType.parse(fieldInfo.dataTypeID));
|
|
17
|
-
const key = new RdhKey(fieldInfo.name, GeneralColumnType.parse(name), super.resolveColumnComment(fieldInfo.name, resolver));
|
|
17
|
+
const name = enum_values_1.EnumValues.getNameFromValue(resource_1.PostgresColumnType, resource_1.PostgresColumnType.parse(fieldInfo.dataTypeID));
|
|
18
|
+
const key = new resource_1.RdhKey(fieldInfo.name, resource_1.GeneralColumnType.parse(name), super.resolveColumnComment(fieldInfo.name, resolver));
|
|
18
19
|
return key;
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
connectSub() {
|
|
22
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
let errorReason = '';
|
|
24
|
+
const options = Object.assign({
|
|
25
|
+
port: 5432,
|
|
26
|
+
host: '127.0.0.1',
|
|
27
|
+
database: 'postgres',
|
|
28
|
+
}, {
|
|
29
|
+
max: 1,
|
|
30
|
+
idleTimeoutMillis: 3000,
|
|
31
|
+
connectionTimeoutMillis: 1000,
|
|
32
|
+
port: this.conRes.port,
|
|
33
|
+
host: this.conRes.host,
|
|
34
|
+
user: this.conRes.user,
|
|
35
|
+
password: this.conRes.password,
|
|
36
|
+
database: this.conRes.database,
|
|
37
|
+
});
|
|
38
|
+
this.pool = new pg_1.default.Pool(options);
|
|
39
|
+
errorReason = yield this.test();
|
|
40
|
+
return errorReason;
|
|
35
41
|
});
|
|
36
|
-
this.pool = new pg.Pool(options);
|
|
37
|
-
errorReason = await this.test();
|
|
38
|
-
return errorReason;
|
|
39
42
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
test(with_connect = false) {
|
|
44
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
let errorReason = '';
|
|
46
|
+
try {
|
|
47
|
+
if (with_connect) {
|
|
48
|
+
errorReason = yield this.connect();
|
|
49
|
+
}
|
|
50
|
+
const rdh = yield this.requestSql('SELECT NOW()');
|
|
51
|
+
if (rdh && rdh.errorMessage) {
|
|
52
|
+
errorReason = rdh.errorMessage;
|
|
53
|
+
}
|
|
45
54
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
errorReason = rdh.errorMessage;
|
|
55
|
+
catch (e) {
|
|
56
|
+
errorReason = e.message;
|
|
49
57
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
finally {
|
|
55
|
-
if (with_connect) {
|
|
56
|
-
await this.disconnect();
|
|
58
|
+
finally {
|
|
59
|
+
if (with_connect) {
|
|
60
|
+
yield this.disconnect();
|
|
61
|
+
}
|
|
57
62
|
}
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
return errorReason;
|
|
64
|
+
});
|
|
60
65
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
requestSql(sql, options) {
|
|
67
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
let rdh = new resource_1.ResultSetDataHolder([]);
|
|
69
|
+
try {
|
|
70
|
+
let binds = [];
|
|
71
|
+
if (options && options.binds) {
|
|
72
|
+
binds = options.binds;
|
|
73
|
+
}
|
|
74
|
+
const results = yield this.pool.query(sql, binds);
|
|
75
|
+
if (results) {
|
|
76
|
+
let resolver;
|
|
77
|
+
if (options && options.needs_column_resolve === true) {
|
|
78
|
+
resolver = this.createColumnResolver(sql);
|
|
79
|
+
}
|
|
80
|
+
const fields = results.fields;
|
|
81
|
+
rdh = new resource_1.ResultSetDataHolder(fields === undefined
|
|
82
|
+
? []
|
|
83
|
+
: fields.map((f) => this.fieldInfo2Key(f, resolver)));
|
|
84
|
+
if (results.rows) {
|
|
85
|
+
results.rows.forEach((result) => {
|
|
86
|
+
rdh.addRow(result);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
67
90
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
91
|
+
catch (err) {
|
|
92
|
+
rdh = resource_1.ResultSetDataHolder.create(err);
|
|
93
|
+
}
|
|
94
|
+
return rdh;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
countTables(tables, options) {
|
|
98
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const list = new Array();
|
|
100
|
+
let counter = 1;
|
|
101
|
+
for (const st of tables.list) {
|
|
102
|
+
let prefix = '';
|
|
103
|
+
if (st.schema) {
|
|
104
|
+
prefix = st.schema + '.';
|
|
105
|
+
}
|
|
106
|
+
if (options && options.progress_callback) {
|
|
107
|
+
if (counter % 5 === 0) {
|
|
108
|
+
options.progress_callback(`Count ${prefix}${st.table}`, 70);
|
|
109
|
+
}
|
|
73
110
|
}
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
111
|
+
const sql = `SELECT COUNT(*) as count FROM ${prefix}${st.table}`;
|
|
112
|
+
try {
|
|
113
|
+
const results = yield this.pool.query(sql, []);
|
|
114
|
+
if (results && results.rows && results.rows.length > 0) {
|
|
115
|
+
const row = results.rows[0];
|
|
116
|
+
const obj = Object.assign({ count: row.count }, st);
|
|
117
|
+
list.push(obj);
|
|
118
|
+
}
|
|
82
119
|
}
|
|
120
|
+
catch (e) { }
|
|
121
|
+
counter++;
|
|
83
122
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
rdh = ResultSetDataHolder.create(err);
|
|
87
|
-
}
|
|
88
|
-
return rdh;
|
|
123
|
+
return list;
|
|
124
|
+
});
|
|
89
125
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
let prefix = '';
|
|
95
|
-
if (st.schema) {
|
|
96
|
-
prefix = st.schema + '.';
|
|
126
|
+
getInfomationSchemas(options) {
|
|
127
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
if (!this.conRes) {
|
|
129
|
+
return [];
|
|
97
130
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
131
|
+
const dbResources = new Array();
|
|
132
|
+
const db_list = yield this.asyncGetDatabases(this.conRes.database);
|
|
133
|
+
db_list.forEach((db) => dbResources.push(db));
|
|
134
|
+
const dbDatabase = db_list.find((d) => d.name === this.conRes.database);
|
|
135
|
+
const dbSchemas = yield this.getSchemas(dbDatabase);
|
|
136
|
+
dbSchemas.forEach((res) => {
|
|
137
|
+
dbDatabase.addChild(res);
|
|
138
|
+
});
|
|
139
|
+
this.resetDefaultSchema(dbDatabase);
|
|
140
|
+
for (const dbSchema of dbSchemas) {
|
|
141
|
+
const dbTables = yield this.getTables(dbSchema);
|
|
142
|
+
dbTables.forEach((res) => dbSchema.addChild(res));
|
|
102
143
|
}
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const row = results.rows[0];
|
|
108
|
-
const obj = Object.assign({ count: row.count }, st);
|
|
109
|
-
list.push(obj);
|
|
144
|
+
for (const dbSchema of dbSchemas) {
|
|
145
|
+
for (const dbTable of dbSchema.getChildren()) {
|
|
146
|
+
const dbColumns = yield this.getColumns(dbTable);
|
|
147
|
+
dbColumns.forEach((res) => dbTable.addChild(res));
|
|
110
148
|
}
|
|
111
149
|
}
|
|
112
|
-
|
|
113
|
-
counter++;
|
|
114
|
-
}
|
|
115
|
-
return list;
|
|
116
|
-
}
|
|
117
|
-
async getInfomationSchemas(options) {
|
|
118
|
-
if (!this.conRes) {
|
|
119
|
-
return [];
|
|
120
|
-
}
|
|
121
|
-
const dbResources = new Array();
|
|
122
|
-
const db_list = await this.asyncGetDatabases(this.conRes.database);
|
|
123
|
-
db_list.forEach((db) => dbResources.push(db));
|
|
124
|
-
const dbDatabase = db_list.find((d) => d.name === this.conRes.database);
|
|
125
|
-
const dbSchemas = await this.getSchemas(dbDatabase);
|
|
126
|
-
dbSchemas.forEach((res) => {
|
|
127
|
-
dbDatabase.addChild(res);
|
|
150
|
+
return dbResources;
|
|
128
151
|
});
|
|
129
|
-
this.resetDefaultSchema(dbDatabase);
|
|
130
|
-
for (const dbSchema of dbSchemas) {
|
|
131
|
-
const dbTables = await this.getTables(dbSchema);
|
|
132
|
-
dbTables.forEach((res) => dbSchema.addChild(res));
|
|
133
|
-
}
|
|
134
|
-
for (const dbSchema of dbSchemas) {
|
|
135
|
-
for (const dbTable of dbSchema.getChildren()) {
|
|
136
|
-
const dbColumns = await this.getColumns(dbTable);
|
|
137
|
-
dbColumns.forEach((res) => dbTable.addChild(res));
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return dbResources;
|
|
141
152
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
153
|
+
asyncGetDatabases(connection_database) {
|
|
154
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
const rdh = yield this
|
|
156
|
+
.requestSql(`SELECT datname AS name, pg_encoding_to_char(encoding) AS comment
|
|
145
157
|
FROM pg_database ORDER BY datname`);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
158
|
+
return rdh.rows.map((r) => {
|
|
159
|
+
const res = new resource_1.DbDatabase(r.values.name);
|
|
160
|
+
res.comment = r.values.comment;
|
|
161
|
+
res.disabled = res.name !== connection_database;
|
|
162
|
+
return res;
|
|
163
|
+
});
|
|
151
164
|
});
|
|
152
165
|
}
|
|
153
|
-
|
|
154
|
-
|
|
166
|
+
getSchemas(dbDatabase) {
|
|
167
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
168
|
+
const rdh = yield this.requestSql(`SELECT SCHEMA_NAME AS name
|
|
155
169
|
FROM INFORMATION_SCHEMA.SCHEMATA
|
|
156
170
|
WHERE LOWER(SCHEMA_NAME) NOT IN ('information_schema', 'sys', 'performance_schema', 'pg_catalog', 'pg_toast', 'pg_temp_1', 'pg_toast_temp_1')
|
|
157
171
|
ORDER BY name`);
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
172
|
+
return rdh.rows.map((r) => {
|
|
173
|
+
const res = new resource_1.DbSchema(r.values.name);
|
|
174
|
+
return res;
|
|
175
|
+
});
|
|
161
176
|
});
|
|
162
177
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
178
|
+
getTables(dbSchema) {
|
|
179
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
let rdh = yield this
|
|
181
|
+
.requestSql(`select quote_ident(m.relname) as qname, COALESCE(d.description, '') as comment
|
|
166
182
|
from pg_stat_all_tables as m
|
|
167
183
|
LEFT JOIN pg_description as d ON (m.relid = d.objoid AND d.objsubid=0)
|
|
168
184
|
WHERE m.schemaname='${dbSchema.getName()}'
|
|
169
185
|
ORDER BY m.relname`);
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
186
|
+
const list = rdh.rows.map((r) => {
|
|
187
|
+
const res = new resource_1.DbTable(r.values.qname, 'TABLE', r.values.comment);
|
|
188
|
+
return res;
|
|
189
|
+
});
|
|
190
|
+
rdh = yield this
|
|
191
|
+
.requestSql(`select quote_ident(viewname) as qname, definition from pg_catalog.pg_views
|
|
176
192
|
where schemaname = '${dbSchema.getName()}'
|
|
177
193
|
order by viewname`);
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
194
|
+
return list.concat(rdh.rows.map((r) => {
|
|
195
|
+
const res = new resource_1.DbTable(r.values.qname, 'VIEW', '');
|
|
196
|
+
return res;
|
|
197
|
+
}));
|
|
198
|
+
});
|
|
182
199
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
200
|
+
getColumns(dbTable) {
|
|
201
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
202
|
+
const binds = [dbTable.getParent().getName(), dbTable.getName()];
|
|
203
|
+
const rdh = yield this.requestSql(`select
|
|
186
204
|
col.COLUMN_NAME as name,
|
|
187
205
|
quote_ident(col.COLUMN_NAME) as qname,
|
|
188
206
|
data_type as col_type,
|
|
@@ -235,27 +253,31 @@ export default class PostgresDriver extends BaseDriver {
|
|
|
235
253
|
col.table_schema = $1 AND quote_ident(col.table_name) = $2
|
|
236
254
|
order by
|
|
237
255
|
col.ordinal_position`, { binds });
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
256
|
+
return rdh.rows.map((r) => {
|
|
257
|
+
const type_name = enum_values_1.EnumValues.getNameFromValue(resource_1.PostgresColumnType, resource_1.PostgresColumnType.parse(r.values.col_type));
|
|
258
|
+
const res = new resource_1.DbColumn(r.values.qname, resource_1.GeneralColumnType.parse(type_name), {
|
|
259
|
+
nullable: r.values.nullable === 1,
|
|
260
|
+
key: r.values.col_key,
|
|
261
|
+
default: r.values.col_default,
|
|
262
|
+
extra: r.values.col_extra,
|
|
263
|
+
}, r.values.comment);
|
|
264
|
+
return res;
|
|
265
|
+
});
|
|
247
266
|
});
|
|
248
267
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
268
|
+
closeSub() {
|
|
269
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
270
|
+
try {
|
|
271
|
+
if (this.pool) {
|
|
272
|
+
yield this.pool.end();
|
|
273
|
+
}
|
|
274
|
+
return '';
|
|
253
275
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
276
|
+
catch (e) {
|
|
277
|
+
return e.message;
|
|
278
|
+
}
|
|
279
|
+
});
|
|
259
280
|
}
|
|
260
281
|
}
|
|
282
|
+
exports.PostgresDriver = PostgresDriver;
|
|
261
283
|
//# sourceMappingURL=PostgresDriver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresDriver.js","sourceRoot":"","sources":["../../../../src/db/drivers/PostgresDriver.ts"],"names":[],"mappings":"AACA,
|
|
1
|
+
{"version":3,"file":"PostgresDriver.js","sourceRoot":"","sources":["../../../../src/db/drivers/PostgresDriver.ts"],"names":[],"mappings":";;;;AACA,6CAA6D;AAC7D,0CAcqB;AACrB,oDAAmC;AACnC,6CAAyC;AAEzC,MAAa,cAAe,SAAQ,uBAAU;IAG5C,YAAY,MAAoB;QAC9B,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IASD,aAAa,CAAC,SAAsB,EAAE,QAAyB;QAC7D,IAAI,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;YACnC,OAAO,CAAC,GAAG,CACT,KAAK,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,MAC5C,SAAS,CAAC,UACZ,EAAE,CACH,CAAC;SACH;QACD,MAAM,IAAI,GAAG,wBAAU,CAAC,gBAAgB,CACtC,6BAAkB,EAClB,6BAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC,CAC/C,CAAC;QACF,MAAM,GAAG,GAAG,IAAI,iBAAM,CACpB,SAAS,CAAC,IAAI,EACd,4BAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,EAC7B,KAAK,CAAC,oBAAoB,CAAC,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,CACrD,CAAC;QACF,OAAO,GAAG,CAAC;IACb,CAAC;IAEK,UAAU;;YACd,IAAI,WAAW,GAAG,EAAE,CAAC;YAErB,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAC3B;gBACE,IAAI,EAAE,IAAI;gBACV,IAAI,EAAE,WAAW;gBACjB,QAAQ,EAAE,UAAU;aACrB,EACD;gB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BACvB;gBACD,OAAO,EAAE,CAAC;aACX;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,CAAC,OAAO,CAAC;aAClB;QACH,CAAC;KAAA;CACF;AAxVD,wCAwVC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import BaseDriver,
|
|
1
|
+
import { BaseDriver, RequestSqlOptions } from './BaseDriver';
|
|
2
2
|
import { DbConnection, DbResource, DbKey, SchemaAndTableHints, TableRows } from '../resource/DbResource';
|
|
3
3
|
import { Redis } from 'ioredis';
|
|
4
|
-
import ResultSetDataHolder from '../resource
|
|
5
|
-
import { RedisKeyType } from '../resource/types/RedisKeyType';
|
|
4
|
+
import { ResultSetDataHolder, RedisKeyType } from '../resource';
|
|
6
5
|
import { RedisRequest } from '../../service/request/RedisRequest';
|
|
7
|
-
export
|
|
6
|
+
export declare class RedisDriver extends BaseDriver {
|
|
8
7
|
client: Redis | undefined;
|
|
9
8
|
databases: number;
|
|
10
9
|
constructor(conRes: DbConnection);
|