forked from mirror/gorm
Respect Where when create index
This commit is contained in:
parent
58596afda1
commit
88188b6161
|
@ -816,7 +816,7 @@ func TestNilPointerSlice(t *testing.T) {
|
|||
}
|
||||
|
||||
var got []Level1
|
||||
if err := DB.Debug().Preload("Level2").Preload("Level2.Level3").Find(&got).Error; err != nil {
|
||||
if err := DB.Preload("Level2").Preload("Level2.Level3").Find(&got).Error; err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
|
|
@ -579,7 +579,9 @@ func (scope *Scope) addIndex(unique bool, indexName string, column ...string) {
|
|||
sqlCreate = "CREATE UNIQUE INDEX"
|
||||
}
|
||||
|
||||
scope.Raw(fmt.Sprintf("%s %v ON %v(%v);", sqlCreate, indexName, scope.QuotedTableName(), strings.Join(columns, ", "))).Exec()
|
||||
scope.Search.Unscoped = true
|
||||
scope.Raw(fmt.Sprintf("%s %v ON %v(%v) %v", sqlCreate, indexName, scope.QuotedTableName(), strings.Join(columns, ", "), scope.whereSql())).Exec()
|
||||
scope.Search.Unscoped = false
|
||||
}
|
||||
|
||||
func (scope *Scope) addForeignKey(field string, dest string, onDelete string, onUpdate string) {
|
||||
|
|
Loading…
Reference in New Issue