2008-05-18 06:22:34 +02:00
|
|
|
require "cases/helper"
|
|
|
|
require 'active_record/schema'
|
2007-02-10 00:12:31 +01:00
|
|
|
|
|
|
|
if ActiveRecord::Base.connection.supports_migrations?
|
|
|
|
class Order < ActiveRecord::Base
|
|
|
|
self.table_name = '[order]'
|
|
|
|
end
|
|
|
|
|
2008-05-18 06:22:34 +02:00
|
|
|
class TableNameTest < ActiveRecord::TestCase
|
2007-02-10 00:12:31 +01:00
|
|
|
self.use_transactional_fixtures = false
|
|
|
|
|
|
|
|
# Ensures Model.columns works when using SQLServer escape characters.
|
|
|
|
# Enables legacy schemas using SQL reserved words as table names.
|
|
|
|
# Should work with table names with spaces as well ('table name').
|
|
|
|
def test_escaped_table_name
|
|
|
|
assert_nothing_raised do
|
|
|
|
ActiveRecord::Base.connection.select_all 'SELECT * FROM [order]'
|
|
|
|
end
|
|
|
|
assert_equal '[order]', Order.table_name
|
|
|
|
assert_equal 5, Order.columns.length
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|