Describe the bug
reform-db init assigns primary key to a wrong column
To Reproduce
Given database schema
CREATE TABLE `builds` (
`i` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`id` varchar(32) NOT NULL,
`name` text NOT NULL,
PRIMARY KEY (`i`),
UNIQUE KEY `id` (`id`)
);
Run reform-db -db-driver MySQL -db-source ... init /package/path
Resulting model:
type Builds struct {
I int64 `reform:"i"`
ID string `reform:"id,pk"`
Name string `reform:"name"`
}
Expected behavior
Expected model is:
type Builds struct {
I int64 `reform:"i,pk"`
ID string `reform:"id"`
Name string `reform:"name"`
}
Additional context
I don't know what happened here. I am new to go so I actually don't want to dig deeper in the source code but I assume primary key recognition relies on a column name being id rather than actual PRIMARY KEY constraint.
Describe the bug reform-db init assigns primary key to a wrong column
To Reproduce
reform-db -db-driver MySQL -db-source ... init /package/path
Expected behavior Expected model is:
Additional context I don't know what happened here. I am new to go so I actually don't want to dig deeper in the source code but I assume primary key recognition relies on a column name being
id
rather than actualPRIMARY KEY
constraint.