I have this model:
type User struct {
gorm.Model
// The Users username
Username string `gorm:"size:255;unique;not null"`
// The Users email address
Email string `gorm:"size:255;unique;not null"`
// The Users hashed password
Password string `gorm:"size:255;not null"`
// The Users password confirmation (only for forms)
PasswordC string `gorm:"-"`
// The Users FULL NAME (e.g. Burt Reynolds)
Fullname string `gorm:"size:255; not null"`
// The Users Karma level
Karma int
// Is the user banned?
Banned bool
}
But PasswordC still shows up in my database using db.AutoMigrate(User{}) I thought gorm:"-" made it be ignored, I wanted to have a PasswordC field for using with Gorilla Schema
Are you using an old version?
I am using the most latest version, my above struct is still creating a PasswordC field in the database:
I just deleted gorm and did a fresh go get github.com/jinzhu/gorm and I deleted the users table but it still comes back with the passwordc field
package models
import (
"log"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/postgres"
)
var DB *gorm.DB
func init() {
db, err := gorm.Open("postgres", "user=postgres dbname=bdo_pug sslmode=disable")
if err != nil {
log.Println(err)
}
DB = db
DB.AutoMigrate(&User{})
}
Seemed to fix it by adding sql:"-" to it but I thought that was the responsibility of the gorm:"-" flag
I don't know why this issue was so quick to close. It is clearly an issue that is still an issue, unless the documentation or the code needs to figure out which one is backwards
http://stackoverflow.com/questions/36963008/gorm-not-ignoring-field-with-gorm/36974118#36974118
Hi @Gacnt
Sorry for this, I made a mistake, as there are some misusage about tags before caused by not upgrade to latest version, I thought this is same issue.
Just fixed this, sorry.
I'm having the same problems using the most recent version of gorm.
type User struct {
gorm.Model
Email string `json:"email" gorm:"column:email"`
/*
...
*/
UserData map[string]interface{} `json:"data" sql:"-" gorm:"-"`
sql: Scan error on column index 9: unsupported driver -> Scan pair: []uint8 -> map[string]interface{}
I'm also having this issue.
I still have problem with this :/
Hi, @mehdy could you write a script and create a new issue to prove that?
Oh, I think I found the problem. I was using glide and it selected the stable version of gorm which was released almost a year ago!
have you considered releasing new versions?
Please release a new version
gorm: "-" still adds the column for me?
Most helpful comment
Please release a new version