Skip to content

Commit

Permalink
Prevent crash in SequelizeStore.set and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Tolga Tezel authored and mweibel committed Mar 5, 2018
1 parent 1eafad8 commit f5b1c6c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/connect-session-sequelize.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ module.exports = function SequelizeSessionInit (Store) {
defaults = this.options.extendDefaultFields(defaults, data)
}

return this.sessionModel.findCreateFind({where: {'sid': sid}, defaults: defaults})
return this.sessionModel.findCreateFind({where: {'sid': sid}, defaults: defaults, raw: false})
.spread(function sessionCreated (session) {
var changed = false
Object.keys(defaults).forEach(function (key) {
Expand Down
15 changes: 15 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,21 @@ describe('#set()', function () {
assert.ok(session.expires instanceof Date, '.expires is not a date')
assert.ok(session.expires > new Date(), '.expires is not in the future')

store.destroy(sessionId, function (err) {
assert.ok(!err, '#destroy() got an error')
done()
})
})
})
it('should have model instance methods', function (done) {
store.set(sessionId, sessionData, function (err, session) {
assert.ok(!err, '#set() got an error')
assert.ok(session, '#set() is not ok')

assert.ok(session.dataValues)
assert.ok(session.update)
assert.ok(session.save)

store.destroy(sessionId, function (err) {
assert.ok(!err, '#destroy() got an error')
done()
Expand Down

0 comments on commit f5b1c6c

Please sign in to comment.