feat: count accpet `db`.`table` (#4626)

* feat: count accpet `db`.`table`

* fix: logic fix
This commit is contained in:
River 2021-08-20 17:37:21 +08:00 committed by GitHub
parent 25f561a742
commit 1bb0d8732d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -390,7 +390,7 @@ func (db *DB) Count(count *int64) (tx *DB) {
if len(tx.Statement.Selects) == 1 { if len(tx.Statement.Selects) == 1 {
dbName := tx.Statement.Selects[0] dbName := tx.Statement.Selects[0]
fields := strings.FieldsFunc(dbName, utils.IsValidDBNameChar) 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 tx.Statement.Parse(tx.Statement.Model) == nil {
if f := tx.Statement.Schema.LookUpField(dbName); f != nil { if f := tx.Statement.Schema.LookUpField(dbName); f != nil {
dbName = f.DBName dbName = f.DBName