gg-mysql-connector 1.0.57 → 1.0.61

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.
@@ -32,6 +32,7 @@ export default class GGMySQLConnector<Main> implements ClassDBInterface<Main> {
32
32
  COLUMN_NAME: string;
33
33
  TABLE_NAME: string;
34
34
  DATA_TYPE: string;
35
+ COLUMN_TYPE: string;
35
36
  }[] | null;
36
37
  isConnected: boolean;
37
38
  constructor(DBInfo: DatabaseConfigInterface);
@@ -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) {
@@ -25,7 +25,7 @@ export default class ModelGenerator {
25
25
  getColumnFullList(tableName: string): Promise<mysql.RowDataPacket[]>;
26
26
  private isTableNameExistInModel;
27
27
  private isColumnExistInModel;
28
- getPossibleColumnValue(model: MyModel[], tableName: string, columnName: string, columnType: string): false | string[] | undefined;
28
+ getPossibleColumnValue(model: MyModel[], tableName: string, columnName: string, columnType: string): string[] | false;
29
29
  generateModelInterface(params: {
30
30
  appName: string;
31
31
  model: MyModel[];
@@ -154,6 +154,7 @@ class ModelGenerator {
154
154
  return word;
155
155
  }
156
156
  }
157
+ return false;
157
158
  }
158
159
  async generateModelInterface(params) {
159
160
  const tableList = [
@@ -8,6 +8,7 @@ export default class MyDBMigrator {
8
8
  TABLE_NAME: string;
9
9
  COLUMN_DEFAULT: string;
10
10
  COLUMN_KEY: string;
11
+ COLUMN_TYPE: string;
11
12
  }[];
12
13
  constructor(connection: ModelGenerator);
13
14
  migrateTable(model: MyModel[]): Promise<void>;
@@ -119,9 +119,7 @@ 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
125
  await this.MyDB.query(`ALTER TABLE ${tableName} MODIFY COLUMN ${columnName} ENUM(${possibleValueString}) ;`);
@@ -179,12 +177,12 @@ class MyDBMigrator {
179
177
  .finally(() => {
180
178
  console.log("");
181
179
  });
182
- loopCount++;
183
180
  if (loopCount > viewModel.length * 5) {
184
181
  console.log("error while updating view, reason is loop update counter is over 5 time fail");
185
182
  process.exit(1);
186
183
  }
187
184
  }
185
+ loopCount++;
188
186
  }
189
187
  }
190
188
  async checkIsPrimaryKey(databaseName, tableName, columnName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gg-mysql-connector",
3
- "version": "1.0.57",
3
+ "version": "1.0.61",
4
4
  "description": "",
5
5
  "main": "dist/src/index.js",
6
6
  "scripts": {
@@ -57,7 +57,12 @@ export default class GGMySQLConnector<Main> implements ClassDBInterface<Main> {
57
57
  isPrintStatement: boolean
58
58
  tableAndViewNameList: string[]
59
59
  columnAndTableListCache:
60
- | { COLUMN_NAME: string; TABLE_NAME: string; DATA_TYPE: string }[]
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 { COLUMN_NAME: string; TABLE_NAME: string; DATA_TYPE: string }[]
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
  }
@@ -171,7 +171,7 @@ export default class ModelGenerator {
171
171
  tableName: string,
172
172
  columnName: string,
173
173
  columnType: string
174
- ) {
174
+ ): string[] | false {
175
175
  const foundTable = model.find((row) => row.tableName === tableName)
176
176
  // search in table model
177
177
  if (foundTable) {
@@ -196,6 +196,7 @@ export default class ModelGenerator {
196
196
  return word
197
197
  }
198
198
  }
199
+ return false
199
200
  }
200
201
  async generateModelInterface(params: {
201
202
  appName: string
@@ -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,9 +198,7 @@ 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 {
@@ -283,7 +282,6 @@ export default class MyDBMigrator {
283
282
  .finally(() => {
284
283
  console.log("")
285
284
  })
286
- loopCount++
287
285
 
288
286
  if (loopCount > viewModel.length * 5) {
289
287
  console.log(
@@ -292,6 +290,7 @@ export default class MyDBMigrator {
292
290
  process.exit(1)
293
291
  }
294
292
  }
293
+ loopCount++
295
294
  }
296
295
  }
297
296