Browse Source

don't change index's columns sort in Equal

xormplus 7 years ago
parent
commit
6bfce2eb88
1 changed files with 8 additions and 4 deletions
  1. 8 4
      index.go

+ 8 - 4
index.go

@@ -2,7 +2,6 @@ package core
 
 import (
 	"fmt"
-	"sort"
 	"strings"
 )
 
@@ -46,11 +45,16 @@ func (index *Index) Equal(dst *Index) bool {
 	if len(index.Cols) != len(dst.Cols) {
 		return false
 	}
-	sort.StringSlice(index.Cols).Sort()
-	sort.StringSlice(dst.Cols).Sort()
 
 	for i := 0; i < len(index.Cols); i++ {
-		if index.Cols[i] != dst.Cols[i] {
+		var found bool
+		for j := 0; j < len(dst.Cols); j++ {
+			if index.Cols[i] == dst.Cols[j] {
+				found = true
+				break
+			}
+		}
+		if !found {
 			return false
 		}
 	}