What version of Go am I using (go version
)?
Go version Go 1.9.1 Linux/amd64
Which database and its version am I using?
sqlite3
A complete runnable program to reproduce my issue:
Need to runnable with GORM's docker compose config or please provide your config.
package main
import (
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/sqlite"
)
type A struct {
ID int
Bs [] *B `gorm:"foreignkey:AID"`
}
type B struct {
ID int
AID int
Config Config `gorm:"type:text"`
}
type Config struct {
attr1 int
attr2 string
}
func main() {
Db, err := gorm.Open("sqlite3", "test.db")
if err != nil {
panic(err)
}
Db.CreateTable(&A{})
Db.CreateTable(&B{})
}
However, the schema of test.db is
sqlite> .schema
CREATE TABLE "as" ("id" integer primary key autoincrement );
CREATE TABLE "bs" ("id" integer primary key autoincrement,"a_id" integer );
As we can see, B's config
attribute was not created.
So Why Gorm is ignoring the Config
struct?