gg-mysql-connector 1.0.55 → 1.0.59
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/src/GGMySQLConnector/GGMySQLConnector.d.ts +1 -0
- package/dist/src/GGMySQLConnector/GGMySQLConnector.js +1 -1
- package/dist/src/MyDBMigrator/MyDBMigrator.d.ts +1 -0
- package/dist/src/MyDBMigrator/MyDBMigrator.js +2 -4
- package/package.json +1 -1
- package/src/GGMySQLConnector/GGMySQLConnector.ts +14 -3
- package/src/MyDBMigrator/MyDBMigrator.ts +3 -4
|
@@ -228,7 +228,7 @@ class GGMySQLConnector {
|
|
|
228
228
|
await this.loadColumnListToCache();
|
|
229
229
|
}
|
|
230
230
|
async loadColumnListToCache() {
|
|
231
|
-
const result = (await this.query(`SELECT COLUMN_NAME,TABLE_NAME,DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '${this.DBInfo.database}'`, undefined, false));
|
|
231
|
+
const result = (await this.query(`SELECT COLUMN_NAME,TABLE_NAME,DATA_TYPE,COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '${this.DBInfo.database}'`, undefined, false));
|
|
232
232
|
this.columnAndTableListCache = result;
|
|
233
233
|
}
|
|
234
234
|
async getColumnList(tableName) {
|
|
@@ -119,12 +119,10 @@ class MyDBMigrator {
|
|
|
119
119
|
const data = this.onetimeLoadColumnContent.find((row) => row.COLUMN_NAME === columnName && row.TABLE_NAME === tableName);
|
|
120
120
|
if (data) {
|
|
121
121
|
let possibleValueString = possibleValue
|
|
122
|
-
.map((row) => {
|
|
123
|
-
return `"${row}"`;
|
|
124
|
-
})
|
|
122
|
+
.map((row) => `"${row}"`)
|
|
125
123
|
.join(", ");
|
|
126
124
|
try {
|
|
127
|
-
await this.MyDB.query(`ALTER TABLE ${tableName} MODIFY COLUMN ${columnName} ENUM(${possibleValueString})
|
|
125
|
+
await this.MyDB.query(`ALTER TABLE ${tableName} MODIFY COLUMN ${columnName} ENUM(${possibleValueString}) ;`);
|
|
128
126
|
}
|
|
129
127
|
catch (e) {
|
|
130
128
|
const data = await this.MyDB.query(`SELECT DISTINCT(${columnName}) as columnValue FROM ${tableName}`);
|
package/package.json
CHANGED
|
@@ -57,7 +57,12 @@ export default class GGMySQLConnector<Main> implements ClassDBInterface<Main> {
|
|
|
57
57
|
isPrintStatement: boolean
|
|
58
58
|
tableAndViewNameList: string[]
|
|
59
59
|
columnAndTableListCache:
|
|
60
|
-
| {
|
|
60
|
+
| {
|
|
61
|
+
COLUMN_NAME: string
|
|
62
|
+
TABLE_NAME: string
|
|
63
|
+
DATA_TYPE: string
|
|
64
|
+
COLUMN_TYPE: string
|
|
65
|
+
}[]
|
|
61
66
|
| null
|
|
62
67
|
isConnected: boolean
|
|
63
68
|
|
|
@@ -374,11 +379,17 @@ export default class GGMySQLConnector<Main> implements ClassDBInterface<Main> {
|
|
|
374
379
|
COLUMN_NAME: string
|
|
375
380
|
TABLE_NAME: string
|
|
376
381
|
DATA_TYPE: string
|
|
382
|
+
COLUMN_TYPE: string
|
|
377
383
|
}[] = (await this.query(
|
|
378
|
-
`SELECT COLUMN_NAME,TABLE_NAME,DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '${this.DBInfo.database}'`,
|
|
384
|
+
`SELECT COLUMN_NAME,TABLE_NAME,DATA_TYPE,COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '${this.DBInfo.database}'`,
|
|
379
385
|
undefined,
|
|
380
386
|
false
|
|
381
|
-
)) as {
|
|
387
|
+
)) as {
|
|
388
|
+
COLUMN_NAME: string
|
|
389
|
+
TABLE_NAME: string
|
|
390
|
+
DATA_TYPE: string
|
|
391
|
+
COLUMN_TYPE: string
|
|
392
|
+
}[]
|
|
382
393
|
|
|
383
394
|
this.columnAndTableListCache = result
|
|
384
395
|
}
|
|
@@ -12,6 +12,7 @@ export default class MyDBMigrator {
|
|
|
12
12
|
TABLE_NAME: string
|
|
13
13
|
COLUMN_DEFAULT: string
|
|
14
14
|
COLUMN_KEY: string
|
|
15
|
+
COLUMN_TYPE: string
|
|
15
16
|
}[]
|
|
16
17
|
constructor(connection: ModelGenerator) {
|
|
17
18
|
this.MyDB = connection
|
|
@@ -197,14 +198,12 @@ export default class MyDBMigrator {
|
|
|
197
198
|
)
|
|
198
199
|
if (data) {
|
|
199
200
|
let possibleValueString = possibleValue
|
|
200
|
-
.map((row) => {
|
|
201
|
-
return `"${row}"`
|
|
202
|
-
})
|
|
201
|
+
.map((row) => `"${row}"`)
|
|
203
202
|
.join(", ")
|
|
204
203
|
|
|
205
204
|
try {
|
|
206
205
|
await this.MyDB.query(
|
|
207
|
-
`ALTER TABLE ${tableName} MODIFY COLUMN ${columnName} ENUM(${possibleValueString})
|
|
206
|
+
`ALTER TABLE ${tableName} MODIFY COLUMN ${columnName} ENUM(${possibleValueString}) ;`
|
|
208
207
|
)
|
|
209
208
|
} catch (e) {
|
|
210
209
|
const data: { columnValue: any }[] = await this.MyDB.query(
|