mirror of https://github.com/go-gorm/gorm.git
Set AutoIncrement to false with tag
This commit is contained in:
parent
97495a5e40
commit
2c68f695c3
|
@ -39,13 +39,10 @@ func (commonDialect) Quote(key string) string {
|
|||
}
|
||||
|
||||
func (s *commonDialect) fieldCanAutoIncrement(field *StructField) bool {
|
||||
// add a new tag "NOT_AUTO_INCREMENT"
|
||||
_, not := field.TagSettings["NOT_AUTO_INCREMENT"]
|
||||
if not {
|
||||
return false
|
||||
if value, ok := field.TagSettings["AUTO_INCREMENT"]; ok {
|
||||
return value != "FALSE"
|
||||
}
|
||||
_, ok := field.TagSettings["AUTO_INCREMENT"]
|
||||
return ok || field.IsPrimaryKey
|
||||
return field.IsPrimaryKey
|
||||
}
|
||||
|
||||
func (s *commonDialect) DataTypeOf(field *StructField) string {
|
||||
|
|
|
@ -72,8 +72,10 @@ func OpenTestConnection() (db *gorm.DB, err error) {
|
|||
|
||||
// db.SetLogger(Logger{log.New(os.Stdout, "\r\n", 0)})
|
||||
// db.SetLogger(log.New(os.Stdout, "\r\n", 0))
|
||||
if os.Getenv("DEBUG") == "true" {
|
||||
if debug := os.Getenv("DEBUG"); debug == "true" {
|
||||
db.LogMode(true)
|
||||
} else if debug == "false" {
|
||||
db.LogMode(false)
|
||||
}
|
||||
|
||||
db.DB().SetMaxIdleConns(10)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
dialects=("postgres" "mysql" "mssql" "sqlite")
|
||||
|
||||
for dialect in "${dialects[@]}" ; do
|
||||
GORM_DIALECT=${dialect} go test
|
||||
DEBUG=false GORM_DIALECT=${dialect} go test
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue