Sha256: 2c713fa55b846064c2170ad0a38686eccc9f7948b284617d440c7714774e82e5

Contents?: true

Size: 744 Bytes

Versions: 25

Compression:

Stored size: 744 Bytes

Contents

require "cases/helper"
require 'active_record/schema'

if ActiveRecord::Base.connection.supports_migrations?
  class Order < ActiveRecord::Base
    self.table_name = '[order]'
  end

  class TableNameTest < ActiveRecord::TestCase
    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

Version data entries

25 entries across 25 versions & 7 rubygems

Version Path
activerecord-2.1.1 test/cases/table_name_test_sqlserver.rb
antfarm-0.3.0 rails/vendor/rails/activerecord/test/cases/table_name_test_sqlserver.rb
antfarm-0.4.0 rails/vendor/rails/activerecord/test/cases/table_name_test_sqlserver.rb
radiant-0.7.0 vendor/rails/activerecord/test/cases/table_name_test_sqlserver.rb
radiant-0.7.1 vendor/rails/activerecord/test/cases/table_name_test_sqlserver.rb