Skip to content
Permalink
Browse files

use LIMIT #, OFFSET # syntax for compat across all database drivers. f…

…ixes #188
  • Loading branch information...
dannyvankooten committed Nov 22, 2018
1 parent 239f880 commit a04307e0dee2a08edf8658829a00faa6dc750e89
Showing with 4 additions and 4 deletions.
  1. +2 −2 pkg/datastore/sqlstore/page_stats.go
  2. +2 −2 pkg/datastore/sqlstore/referrer_stats.go
@@ -53,8 +53,8 @@ func (db *sqlstore) SelectAggregatedPageStats(siteID int64, startDate time.Time,
LEFT JOIN pathnames p ON p.id = s.pathname_id
WHERE site_id = ? AND ts >= ? AND ts <= ?
GROUP BY hostname, pathname
ORDER BY pageviews DESC LIMIT ?, ?`)
err := db.Select(&result, query, siteID, startDate.Format(DATE_FORMAT), endDate.Format(DATE_FORMAT), offset, limit)
ORDER BY pageviews DESC LIMIT ? OFFSET ?`)
err := db.Select(&result, query, siteID, startDate.Format(DATE_FORMAT), endDate.Format(DATE_FORMAT), limit, offset)
return result, err
}

@@ -59,11 +59,11 @@ func (db *sqlstore) SelectAggregatedReferrerStats(siteID int64, startDate time.T
} else {
sql = sql + `GROUP BY COALESCE(NULLIF(groupname, ''), CONCAT(hostname_id, pathname_id) ) `
}
sql = sql + ` ORDER BY pageviews DESC LIMIT ?, ?`
sql = sql + ` ORDER BY pageviews DESC LIMIT ? OFFSET ?`

query := db.Rebind(sql)

err := db.Select(&result, query, siteID, startDate.Format(DATE_FORMAT), endDate.Format(DATE_FORMAT), offset, limit)
err := db.Select(&result, query, siteID, startDate.Format(DATE_FORMAT), endDate.Format(DATE_FORMAT), limit, offset)
return result, mapError(err)
}

0 comments on commit a04307e

Please sign in to comment.
You can’t perform that action at this time.