gg-mysql-connector 1.0.49 → 1.0.53

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.
@@ -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 | null)[] | undefined;
28
+ getPossibleColumnValue(model: MyModel[], tableName: string, columnName: string, columnType: string): false | string[] | undefined;
29
29
  generateModelInterface(params: {
30
30
  appName: string;
31
31
  model: MyModel[];
@@ -17,7 +17,7 @@ export default class MyDBMigrator {
17
17
  private checkIsColumnDataTypeChange;
18
18
  alterUniqueKey(tableName: string, columnName: string, IS_UNIQUE: boolean | undefined): Promise<void>;
19
19
  alterIndex(tableName: string, columnName: string, IS_INDEX: boolean | undefined): Promise<void>;
20
- alterPossibleEnum(tableName: string, columnName: string, possibleValue?: (string | null)[]): Promise<null | undefined>;
20
+ alterPossibleEnum(tableName: string, columnName: string, possibleValue?: string[]): Promise<null | undefined>;
21
21
  migrateView(viewDirectory: string): Promise<0 | undefined>;
22
22
  migrateView_v2(viewModel: MyViewModel[]): Promise<void>;
23
23
  checkIsPrimaryKey(databaseName: string, tableName: string, columnName: string): Promise<boolean>;
@@ -119,15 +119,11 @@ 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
- .filter((row) => row !== null)
123
122
  .map((row) => {
124
123
  return `"${row}"`;
125
124
  })
126
125
  .join(", ");
127
- const nullString = possibleValue.filter((row) => row == null).length > 0
128
- ? "NULL"
129
- : "NOT NULL";
130
- await this.MyDB.query(`ALTER TABLE ${tableName} MODIFY COLUMN ${columnName} ENUM(${possibleValueString}) ${nullString};`);
126
+ await this.MyDB.query(`ALTER TABLE ${tableName} MODIFY COLUMN ${columnName} ENUM(${possibleValueString}) NOT NULL;`);
131
127
  }
132
128
  }
133
129
  async migrateView(viewDirectory) {
@@ -5,7 +5,7 @@ export interface columnContent {
5
5
  DATA_TYPE: columnType;
6
6
  COLUMN_DEFAULT?: string | number | null;
7
7
  AUTO_INCREMENT?: boolean;
8
- POSSIBLE_VALUE?: (string | null)[];
8
+ POSSIBLE_VALUE?: string[];
9
9
  IS_UNIQUE?: boolean;
10
10
  IS_INDEX?: boolean;
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gg-mysql-connector",
3
- "version": "1.0.49",
3
+ "version": "1.0.53",
4
4
  "description": "",
5
5
  "main": "dist/src/index.js",
6
6
  "scripts": {
@@ -189,7 +189,7 @@ export default class MyDBMigrator {
189
189
  async alterPossibleEnum(
190
190
  tableName: string,
191
191
  columnName: string,
192
- possibleValue?: (string | null)[]
192
+ possibleValue?: string[]
193
193
  ) {
194
194
  if (!possibleValue) return null
195
195
  const data = this.onetimeLoadColumnContent.find(
@@ -197,19 +197,13 @@ export default class MyDBMigrator {
197
197
  )
198
198
  if (data) {
199
199
  let possibleValueString = possibleValue
200
- .filter((row) => row !== null)
201
200
  .map((row) => {
202
201
  return `"${row}"`
203
202
  })
204
203
  .join(", ")
205
204
 
206
- const nullString =
207
- possibleValue.filter((row) => row == null).length > 0
208
- ? "NULL"
209
- : "NOT NULL"
210
-
211
205
  await this.MyDB.query(
212
- `ALTER TABLE ${tableName} MODIFY COLUMN ${columnName} ENUM(${possibleValueString}) ${nullString};`
206
+ `ALTER TABLE ${tableName} MODIFY COLUMN ${columnName} ENUM(${possibleValueString}) NOT NULL;`
213
207
  )
214
208
  }
215
209
  }
package/src/myModel.ts CHANGED
@@ -22,7 +22,7 @@ export interface columnContent {
22
22
  DATA_TYPE: columnType
23
23
  COLUMN_DEFAULT?: string | number | null
24
24
  AUTO_INCREMENT?: boolean
25
- POSSIBLE_VALUE?: (string | null)[]
25
+ POSSIBLE_VALUE?: string[]
26
26
  IS_UNIQUE?: boolean
27
27
  IS_INDEX?: boolean
28
28
  }