forked from mirror/gorm
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 {
|
func (s *commonDialect) fieldCanAutoIncrement(field *StructField) bool {
|
||||||
// add a new tag "NOT_AUTO_INCREMENT"
|
if value, ok := field.TagSettings["AUTO_INCREMENT"]; ok {
|
||||||
_, not := field.TagSettings["NOT_AUTO_INCREMENT"]
|
return value != "FALSE"
|
||||||
if not {
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
_, ok := field.TagSettings["AUTO_INCREMENT"]
|
return field.IsPrimaryKey
|
||||||
return ok || field.IsPrimaryKey
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *commonDialect) DataTypeOf(field *StructField) string {
|
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(Logger{log.New(os.Stdout, "\r\n", 0)})
|
||||||
// db.SetLogger(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)
|
db.LogMode(true)
|
||||||
|
} else if debug == "false" {
|
||||||
|
db.LogMode(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
db.DB().SetMaxIdleConns(10)
|
db.DB().SetMaxIdleConns(10)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
dialects=("postgres" "mysql" "mssql" "sqlite")
|
dialects=("postgres" "mysql" "mssql" "sqlite")
|
||||||
|
|
||||||
for dialect in "${dialects[@]}" ; do
|
for dialect in "${dialects[@]}" ; do
|
||||||
GORM_DIALECT=${dialect} go test
|
DEBUG=false GORM_DIALECT=${dialect} go test
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue