From bf8c28b5db42ce40eb025a4136cb8356d58630d9 Mon Sep 17 00:00:00 2001 From: jiangyang Date: Mon, 18 Mar 2024 14:51:11 +0800 Subject: [PATCH] fix: Fixed the problem that the return result of ShardingSuffixs cannot 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. --- sharding.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sharding.go b/sharding.go index 04f8448..85b2738 100644 --- a/sharding.go +++ b/sharding.go @@ -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 }