1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix SqlBypass.data_column= problem. SqlBypass.find_by_session_id method didn't use this assignment.

This commit is contained in:
kennyj 2012-07-15 01:35:05 +09:00
parent 088022ef26
commit cd44862d72
2 changed files with 15 additions and 1 deletions

View file

@ -218,7 +218,7 @@ module ActiveRecord
# 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

View file

@ -56,6 +56,20 @@ module ActiveRecord
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