2008-01-21 12:20:51 -05:00
|
|
|
require "cases/helper"
|
2008-01-18 02:31:37 -05:00
|
|
|
require 'models/topic'
|
2005-01-20 09:55:13 -05:00
|
|
|
|
2008-01-21 12:20:51 -05:00
|
|
|
class TestColumnAlias < ActiveRecord::TestCase
|
2005-10-23 15:02:38 -04:00
|
|
|
fixtures :topics
|
|
|
|
|
2006-03-01 11:01:53 -05:00
|
|
|
QUERY = if 'Oracle' == ActiveRecord::Base.connection.adapter_name
|
2005-10-23 15:02:38 -04:00
|
|
|
'SELECT id AS pk FROM topics WHERE ROWNUM < 2'
|
|
|
|
else
|
|
|
|
'SELECT id AS pk FROM topics'
|
|
|
|
end
|
2005-01-20 09:55:13 -05:00
|
|
|
|
|
|
|
def test_column_alias
|
2005-10-23 15:02:38 -04:00
|
|
|
records = Topic.connection.select_all(QUERY)
|
|
|
|
assert_equal 'pk', records[0].keys[0]
|
2005-01-20 09:55:13 -05:00
|
|
|
end
|
|
|
|
end
|