mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-10-01 16:21:20 +00:00
fix: 修复主键类型非Integer时的模型生成与导入问题
1. 前端将MySQL主键默认类型从bigint改为int,同步后端代码适配 2. 增加SQLAlchemy主键类型自动导入逻辑,当主键类型不是Integer时自动添加对应导入 3. 重构模型模板,当主键类型与基类不一致时显式覆盖id字段定义
This commit is contained in:
@@ -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"}`,
|
||||
|
||||
Reference in New Issue
Block a user