Skip to content

Commit

Permalink
fix(admin): fixed table query error
Browse files Browse the repository at this point in the history
  • Loading branch information
cg33 committed Feb 3, 2021
1 parent 3662ae6 commit 4f0aea6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions plugins/admin/modules/table/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,12 +458,12 @@ func (tb *DefaultTable) getDataFromDatabase(params parameter.Parameters) (PanelI
queryStatement = "SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY %s." + placeholder + " %s) as ROWNUMBER_, %s from " +
placeholder + "%s %s %s ) as TMP_ WHERE TMP_.ROWNUMBER_ > ? AND TMP_.ROWNUMBER_ <= ?"
// %s means: table, join table, wheres
countStatement = "select count(*) as [size] from " + placeholder + " %s"
countStatement = "select count(*) as [size] from (select count(*) as [size] from " + placeholder + " %s %s %s) src"
} else {
// %s means: fields, table, join table, wheres, group by, order by field, order by type
queryStatement = "select %s from " + placeholder + "%s %s %s order by " + placeholder + "." + placeholder + " %s LIMIT ? OFFSET ?"
// %s means: table, join table, wheres
countStatement = "select count(*) from " + placeholder + "%s"
countStatement = "select count(*) from (select count(*) from " + placeholder + " %s %s %s) src"
}
}

Expand Down Expand Up @@ -565,7 +565,7 @@ func (tb *DefaultTable) getDataFromDatabase(params parameter.Parameters) (PanelI
var size int

if len(ids) == 0 {
countCmd := fmt.Sprintf(countStatement, tb.Info.Table, wheres)
countCmd := fmt.Sprintf(countStatement, tb.Info.Table, joins, wheres, groupBy)

total, err := connection.QueryWithConnection(tb.connection, countCmd, whereArgs...)

Expand Down

0 comments on commit 4f0aea6

Please sign in to comment.