From 44eb1e8a223f7716aa6c4a5244f3cd66f9176b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Lindstr=C3=B6m?= Date: Wed, 9 Sep 2015 05:43:02 +0000 Subject: [PATCH] Add underscores when querying column names This commit aims to fix tests which fails on not finding columns such as `expireson`. Adding the underscore that are used when creating the table should fix this. An issue with this is that it must have worked previously without underscores. In that case this might break existing usage. --- cleanup.go | 2 +- cleanup_test.go | 2 +- pgstore.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cleanup.go b/cleanup.go index f003c05..5a5caed 100644 --- a/cleanup.go +++ b/cleanup.go @@ -53,6 +53,6 @@ func (db *PGStore) cleanup(interval time.Duration, quit <-chan struct{}, done ch // deleteExpired deletes expired sessions from the database. func (db *PGStore) deleteExpired() error { - _, err := db.DbMap.Exec("DELETE FROM http_sessions WHERE expireson < now()") + _, err := db.DbMap.Exec("DELETE FROM http_sessions WHERE expires_on < now()") return err } diff --git a/cleanup_test.go b/cleanup_test.go index 1b18679..8642d22 100644 --- a/cleanup_test.go +++ b/cleanup_test.go @@ -40,7 +40,7 @@ func TestCleanup(t *testing.T) { // SELECT expired sessions. We should get a zero-length result slice back. var results []int64 - _, err = ss.DbMap.Select(&results, "SELECT id FROM http_sessions WHERE expireson < now()") + _, err = ss.DbMap.Select(&results, "SELECT id FROM http_sessions WHERE expires_on < now()") if err != nil { t.Fatalf("failed to select expired sessions from DB: %v", err) } diff --git a/pgstore.go b/pgstore.go index e3be094..d9debc2 100644 --- a/pgstore.go +++ b/pgstore.go @@ -218,7 +218,7 @@ func (db *PGStore) save(session *sessions.Session) error { if session.IsNew { err = db.DbMap.Insert(&s) } else { - _, err = db.DbMap.Exec("update http_sessions set data=$1, modifiedon=$2, expireson=$3 where key=$4", s.Data, s.ModifiedOn, s.ExpiresOn, s.Key) + _, err = db.DbMap.Exec("update http_sessions set data=$1, modified_on=$2, expires_on=$3 where key=$4", s.Data, s.ModifiedOn, s.ExpiresOn, s.Key) } return err