Skip to content

[BUG] DBML with field length definitions triggers SQL generation errors #1051

Description

@ludengke95

Describe the bug
Create a generic-type diagram. After importing DBML, if the DBML contains field length specifications, the table column types will be displayed in the format such as VARCHAR(50). When exporting to MySQL, these types are recognized as custom types, causing an export error with an "undefined" prompt. After troubleshooting and fixing the problem, all column types in the exported SQL are unexpectedly converted to JSON.

To Reproduce
Steps to reproduce the behavior:

  1. Navigate to File -> Import from -> DBML
  2. Navigate to File -> Export SQL -> MySQL

Expected behavior
Can correctly display MySQL DDL

Screenshots

Image Image Image

Desktop (please complete the following information):

  • OS: Windows 11
  • Browser: chrome

Additional context
I have checked the DBML specification, which allows specifying field lengths in data types. DBML column-settings

DBML

Table sys_user {
  id bigint [pk, increment, note: "用户主键ID"]
  username varchar(50) [unique, not null, note: "登录账号"]
  password varchar(100) [not null, note: "加密密码"]
  real_name varchar(30) [not null, note: "真实姓名"]
  phone varchar(20) [note: "手机号"]
  email varchar(100) [note: "邮箱"]
  avatar varchar(255) [note: "头像地址"]
  status tinyint [default: 1, note: "0禁用 1正常"]
  role_id bigint [ref: > sys_role.id, note: "角色ID"]
  create_at datetime [note: "创建时间", default: `now()`]
  update_at datetime [note: "更新时间"]
}

Table sys_role {
  id bigint [pk, increment]
  role_name varchar(50) [not null, unique, note: "角色名称"]
  role_code varchar(50) [not null, unique, note: "角色编码 admin/stock/sale"]
  remark varchar(255) [note: "角色备注"]
  create_at datetime
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions