mirror of
https://github.com/hanzoai/xorm.git
synced 2026-10-01 00:49:40 +00:00
Remove dead code from session.SyncWithOptions() (#2323)
https://gitea.com/xorm/xorm/src/commit/b61c9ac22e0fb7e560acefa6c8cd68687c4d8cb2/sync.go#L229-L231 as oriIndex only is **not** nil if index.Equal(index2) and index.Equal(index2) check if `oriIndex.Type == index.Type` ... so it always is false Co-authored-by: Lunny Xiao <[email protected]> Reviewed-on: https://gitea.com/xorm/xorm/pulls/2323 Reviewed-by: Lunny Xiao <[email protected]> Co-authored-by: 6543 <[email protected]> Co-committed-by: 6543 <[email protected]>
This commit is contained in:
committed by
Lunny Xiao
co-authored by
Lunny Xiao
parent
8327d05fa5
commit
c122cfd093
@@ -235,15 +235,6 @@ func (session *Session) SyncWithOptions(opts SyncOptions, beans ...interface{})
|
||||
}
|
||||
}
|
||||
|
||||
if oriIndex != nil && oriIndex.Type != index.Type {
|
||||
sql := engine.dialect.DropIndexSQL(tbNameWithSchema, oriIndex)
|
||||
_, err = session.exec(sql)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
oriIndex = nil
|
||||
}
|
||||
|
||||
if oriIndex == nil {
|
||||
addedNames[name] = index
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
// Copyright 2023 The Xorm Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package tests
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
type TestSync1 struct {
|
||||
Id int64
|
||||
ClassId int64 `xorm:"index"`
|
||||
}
|
||||
|
||||
func (TestSync1) TableName() string {
|
||||
return "test_sync"
|
||||
}
|
||||
|
||||
type TestSync2 struct {
|
||||
Id int64
|
||||
ClassId int64 `xorm:"unique"`
|
||||
}
|
||||
|
||||
func (TestSync2) TableName() string {
|
||||
return "test_sync"
|
||||
}
|
||||
|
||||
func TestSync(t *testing.T) {
|
||||
assert.NoError(t, testEngine.Sync(new(TestSync1)))
|
||||
assert.NoError(t, testEngine.Sync(new(TestSync2)))
|
||||
}
|
||||
Reference in New Issue
Block a user