@shys/crud 1.0.1-beta.5 → 1.0.1-beta.6

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.
Files changed (2) hide show
  1. package/dist/db.js +3 -2
  2. package/package.json +1 -1
package/dist/db.js CHANGED
@@ -52,7 +52,7 @@ export async function getTableFieldsFromDb(dbConfig, tableName) {
52
52
  database: database || '',
53
53
  });
54
54
  try {
55
- const [rows] = await connection.execute(`SELECT column_name, data_type, is_nullable, column_type, column_comment, column_default, character_maximum_length, extra
55
+ const [rows] = await connection.execute(`SELECT column_name, data_type, is_nullable, column_type, column_comment, column_default, character_maximum_length, extra, column_key
56
56
  FROM information_schema.COLUMNS
57
57
  WHERE table_schema = ? AND table_name = ?
58
58
  ORDER BY ordinal_position`, [database, tableName]);
@@ -68,7 +68,8 @@ export async function getTableFieldsFromDb(dbConfig, tableName) {
68
68
  const defaultVal = row.COLUMN_DEFAULT || row.column_default;
69
69
  const length = row.CHARACTER_MAXIMUM_LENGTH || row.character_maximum_length;
70
70
  const extra = row.EXTRA || row.extra || '';
71
- const isPk = extra.includes('PRI') || columnName.toLowerCase().includes('id');
71
+ const columnKey = row.COLUMN_KEY || row.column_key || '';
72
+ const isPk = columnKey === 'PRI';
72
73
  const isAuto = extra.includes('auto_increment');
73
74
  return {
74
75
  name: columnName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shys/crud",
3
- "version": "1.0.1-beta.5",
3
+ "version": "1.0.1-beta.6",
4
4
  "description": "MidwayJS v4 模块化 CRUD CLI 生成器",
5
5
  "license": "MIT",
6
6
  "author": {