From a04307e0dee2a08edf8658829a00faa6dc750e89 Mon Sep 17 00:00:00 2001 From: Danny van Kooten Date: Thu, 22 Nov 2018 21:19:52 +0100 Subject: [PATCH] use LIMIT #, OFFSET # syntax for compat across all database drivers. fixes #188 --- pkg/datastore/sqlstore/page_stats.go | 4 ++-- pkg/datastore/sqlstore/referrer_stats.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/datastore/sqlstore/page_stats.go b/pkg/datastore/sqlstore/page_stats.go index 6415839a..c26e0ef7 100644 --- a/pkg/datastore/sqlstore/page_stats.go +++ b/pkg/datastore/sqlstore/page_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 } diff --git a/pkg/datastore/sqlstore/referrer_stats.go b/pkg/datastore/sqlstore/referrer_stats.go index 9f20b1c3..4507aaa4 100644 --- a/pkg/datastore/sqlstore/referrer_stats.go +++ b/pkg/datastore/sqlstore/referrer_stats.go @@ -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) }