Skip to content

Commit

Permalink
fix: Fixed the problem that the return result of ShardingSuffixs cann…
Browse files Browse the repository at this point in the history
…ot be correctly matched when using string type table suffix.

Fixed the problem that the return result of ShardingSuffixs cannot be correctly matched when using string type table suffix.
  • Loading branch information
geekeryy authored Mar 18, 2024
1 parent 4cb9491 commit bf8c28b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sharding.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,9 @@ func (s *Sharding) resolve(query string, args ...any) (ftQuery, stQuery, tableNa
suffixWord := strings.Replace(suffix, "_", "", 1)
tblIdx, err := strconv.Atoi(suffixWord)
if err != nil {
tblIdx = slices.Index(r.ShardingSuffixs(), suffixWord)
tblIdx = slices.Index(r.ShardingSuffixs(), suffix)
if tblIdx == -1 {
return ftQuery, stQuery, tableName, errors.New("table suffix '" + suffixWord + "' is not in ShardingSuffixs. In order to generate the primary key, ShardingSuffixs should include all table suffixes")
return ftQuery, stQuery, tableName, errors.New("table suffix '" + suffix + "' is not in ShardingSuffixs. In order to generate the primary key, ShardingSuffixs should include all table suffixes")
}
//return ftQuery, stQuery, tableName, err
}
Expand Down

0 comments on commit bf8c28b

Please sign in to comment.