aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/column_alias_test.rb
blob: f84d584eee4b2ee4365629a1a8773491ba93640d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
require 'abstract_unit'
require 'fixtures/topic'

class TestColumnAlias < Test::Unit::TestCase

  def test_column_alias
    topic = Topic.find(1)
    if ActiveRecord::ConnectionAdapters.const_defined? :OracleAdapter
      if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::OracleAdapter)
        records = topic.connection.select_all("SELECT id AS pk FROM topics WHERE ROWNUM < 2")
        assert_equal(records[0].keys[0], "pk")
      end
    else
      records = topic.connection.select_all("SELECT id AS pk FROM topics")
      assert_equal(records[0].keys[0], "pk")
    end
  end
  
end