Is this a select count(*) FROM ... query?
()
| 1276 | |
| 1277 | // Is this a select count(*) FROM ... query? |
| 1278 | func (m *SqlSelect) CountStar() bool { |
| 1279 | if len(m.Columns) != 1 { |
| 1280 | return false |
| 1281 | } |
| 1282 | col := m.Columns[0] |
| 1283 | if col.Expr == nil { |
| 1284 | return false |
| 1285 | } |
| 1286 | if f, ok := col.Expr.(*expr.FuncNode); ok { |
| 1287 | if strings.ToLower(f.Name) != "count" { |
| 1288 | return false |
| 1289 | } |
| 1290 | if len(f.Args) == 1 && f.Args[0].String() == "*" { |
| 1291 | return true |
| 1292 | } |
| 1293 | } |
| 1294 | return false |
| 1295 | } |
| 1296 | |
| 1297 | // Rewrite take current SqlSelect statement and re-write it |
| 1298 | func (m *SqlSelect) Rewrite() { |