fix: 修复主键类型非Integer时的模型生成与导入问题

1. 前端将MySQL主键默认类型从bigint改为int,同步后端代码适配
2. 增加SQLAlchemy主键类型自动导入逻辑,当主键类型不是Integer时自动添加对应导入
3. 重构模型模板,当主键类型与基类不一致时显式覆盖id字段定义
This commit is contained in:
zhangtao
2026-09-13 22:17:49 +08:00
parent 8291c1a494
commit f12a40090a
4 changed files with 58 additions and 2 deletions
@@ -94,7 +94,7 @@ function pkMysql(): ColDef[] {
return [
{
name: "id",
type: "bigint",
type: "int",
nullable: false,
isPk: true,
comment: "主键ID",
@@ -129,7 +129,7 @@ function buildSubColumns(dialect: SqlDialect, mainTableName: string, fkColumn: s
const subPk = isMysql ? pkMysql() : pkPostgres();
const fkColDef: ColDef = {
name: fkColumn,
type: "bigint",
type: isMysql ? "int" : "integer",
nullable: false,
isPk: false,
comment: `关联 ${mainTableName}.${"id"}`,