Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

primarykey 判断错误 导致gen生成的model 存在问题 #158

Open
mimicode opened this issue Aug 23, 2024 · 0 comments
Open

primarykey 判断错误 导致gen生成的model 存在问题 #158

mimicode opened this issue Aug 23, 2024 · 0 comments
Assignees

Comments

@mimicode
Copy link

GORM Playground Link

go-gorm/playground#1

Description

1.建表

CREATE TABLE `mytest_table` (
  `column1` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  `column2` char(40) COLLATE utf8mb4_unicode_ci NOT NULL,
  `column3` tinyint(3) unsigned NOT NULL DEFAULT '0',
  UNIQUE KEY `unikkkk` (`column1`,`column2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

2.查询字段信息
image

  1. 实际该 column1,column2 并不是主键。这里判断
    代码判断处 存在逻辑问题,也许是MySQL本身的bug,但这里应该修复
    [](
    case "PRI":
    )

4.导致gen生成的model
image

  1. 可能不是准确的修复方法(但目前能解决问题)
    image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants