2017-07-09 13:41:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2011-06-06 14:17:44 -04:00
|
|
|
require "cases/helper"
|
2016-08-06 12:26:20 -04: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
|
|
|
|
|
2016-08-06 12:26:20 -04:00
|
|
|
QUERY = if "Oracle" == ActiveRecord::Base.connection.adapter_name
|
2016-08-06 13:55:02 -04:00
|
|
|
"SELECT id AS pk FROM topics WHERE ROWNUM < 2"
|
2016-08-07 17:41:00 -04:00
|
|
|
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)
|
2016-08-06 12:26:20 -04:00
|
|
|
assert_equal "pk", records[0].keys[0]
|
2005-01-20 09:55:13 -05:00
|
|
|
end
|
|
|
|
end
|