Skip to content

Commit

Permalink
Fix SqlBypass.data_column= problem. SqlBypass.find_by_session_id meth…
Browse files Browse the repository at this point in the history
…od didn't use this assignment.
  • Loading branch information
kennyj committed Jul 14, 2012
1 parent 088022e commit cd44862
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/session_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def connection_pool

# Look up a session by id and unmarshal its data if found.
def find_by_session_id(session_id)
if record = connection.select_one("SELECT * FROM #{@@table_name} WHERE #{@@session_id_column}=#{connection.quote(session_id.to_s)}")
if record = connection.select_one("SELECT #{connection.quote_column_name(data_column)} AS data FROM #{@@table_name} WHERE #{connection.quote_column_name(@@session_id_column)}=#{connection.quote(session_id.to_s)}")
new(:session_id => session_id, :marshaled_data => record['data'])
end
end
Expand Down
14 changes: 14 additions & 0 deletions activerecord/test/cases/session_store/sql_bypass_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ def test_destroy
s.destroy
assert_nil SqlBypass.find_by_session_id session_id
end

def test_data_column
SqlBypass.drop_table! if exists = Session.table_exists?
old, SqlBypass.data_column = SqlBypass.data_column, 'foo'
SqlBypass.create_table!

session_id = 20
SqlBypass.new(:data => 'hello', :session_id => session_id).save
assert_equal 'hello', SqlBypass.find_by_session_id(session_id).data
ensure
SqlBypass.drop_table!
SqlBypass.data_column = old
SqlBypass.create_table! if exists
end
end
end
end

0 comments on commit cd44862

Please sign in to comment.