Merge pull request #14 from antonlindstrom/bugfix/column-names-underscores

Add underscores when querying column names
This commit is contained in:
Anton Lindström 2015-09-15 16:58:32 +02:00
commit 31a178b4b1
3 changed files with 3 additions and 3 deletions

View File

@ -53,6 +53,6 @@ func (db *PGStore) cleanup(interval time.Duration, quit <-chan struct{}, done ch
// deleteExpired deletes expired sessions from the database. // deleteExpired deletes expired sessions from the database.
func (db *PGStore) deleteExpired() error { 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 return err
} }

View File

@ -40,7 +40,7 @@ func TestCleanup(t *testing.T) {
// SELECT expired sessions. We should get a zero-length result slice back. // SELECT expired sessions. We should get a zero-length result slice back.
var results []int64 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 { if err != nil {
t.Fatalf("failed to select expired sessions from DB: %v", err) t.Fatalf("failed to select expired sessions from DB: %v", err)
} }

View File

@ -218,7 +218,7 @@ func (db *PGStore) save(session *sessions.Session) error {
if session.IsNew { if session.IsNew {
err = db.DbMap.Insert(&s) err = db.DbMap.Insert(&s)
} else { } 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 return err