activerecord-session_store icon indicating copy to clipboard operation
activerecord-session_store copied to clipboard

Avoid session lookup when ID is nil

Open EiNSTeiN- opened this issue 4 years ago • 0 comments

During a request when the session is accessed, load_session will call find_session which ends up calling get_session_model. When no session cookie is present in the browser, the id will be nil. Adding id && in this PR avoids an unnecessary database query that would look like:

SELECT `sessions`.* FROM `sessions` WHERE `sessions`.`session_id` IS NULL LIMIT 1

arguably, if this matched a row, that would be a bug.

EiNSTeiN- avatar Sep 17 '20 14:09 EiNSTeiN-