From 28fcf5135b6e74ede983edbf5ddee6e736560414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D0=B5=D0=BC=D1=8C=D0=B5=D0=B2=20=D0=92?= =?UTF-8?q?=D1=8F=D1=87=D0=B5=D1=81=D0=BB=D0=B0=D0=B2?= Date: Wed, 10 Jul 2019 13:33:38 +0300 Subject: [PATCH] Fix github-issue-220: Incorrect query to Pg --- core/database.go | 3 +-- types/time.go | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/core/database.go b/core/database.go index 9d4da4e2..e176ea94 100644 --- a/core/database.go +++ b/core/database.go @@ -101,8 +101,7 @@ func incidentsUpdatesDB() *gorm.DB { func (s *Service) HitsBetween(t1, t2 time.Time, group string, column string) *gorm.DB { selector := Dbtimestamp(group, column) if CoreApp.DbConnection == "postgres" { - timeQuery := fmt.Sprintf("service = %v AND created_at BETWEEN '%v.000000' AND '%v.000000'", s.Id, t1.UTC().Format(types.POSTGRES_TIME), t2.UTC().Format(types.POSTGRES_TIME)) - return hitsDB().Select(selector).Where(timeQuery) + return hitsDB().Select(selector).Where("service = ? AND created_at BETWEEN ? AND ?", s.Id, t1.UTC().Format(types.TIME), t2.UTC().Format(types.TIME)) } else { return hitsDB().Select(selector).Where("service = ? AND created_at BETWEEN ? AND ?", s.Id, t1.UTC().Format(types.TIME_DAY), t2.UTC().Format(types.TIME_DAY)) } diff --git a/types/time.go b/types/time.go index 5d936a2d..b7ededd9 100644 --- a/types/time.go +++ b/types/time.go @@ -22,7 +22,6 @@ import ( const ( TIME_NANO = "2006-01-02T15:04:05Z" TIME = "2006-01-02 15:04:05" - POSTGRES_TIME = "2006-01-02 15:04" CHART_TIME = "2006-01-02T15:04:05.999999-07:00" TIME_DAY = "2006-01-02" )