From 1bb0d8732d2a33d1d796af2591478c7013e36736 Mon Sep 17 00:00:00 2001 From: River Date: Fri, 20 Aug 2021 17:37:21 +0800 Subject: [PATCH] feat: count accpet `db`.`table` (#4626) * feat: count accpet `db`.`table` * fix: logic fix --- finisher_api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/finisher_api.go b/finisher_api.go index 537c955a..34e1596b 100644 --- a/finisher_api.go +++ b/finisher_api.go @@ -390,7 +390,7 @@ func (db *DB) Count(count *int64) (tx *DB) { if len(tx.Statement.Selects) == 1 { dbName := tx.Statement.Selects[0] fields := strings.FieldsFunc(dbName, utils.IsValidDBNameChar) - if len(fields) == 1 || (len(fields) == 3 && strings.ToUpper(fields[1]) == "AS") { + if len(fields) == 1 || (len(fields) == 3 && (strings.ToUpper(fields[1]) == "AS" || fields[1] == ".")) { if tx.Statement.Parse(tx.Statement.Model) == nil { if f := tx.Statement.Schema.LookUpField(dbName); f != nil { dbName = f.DBName