Sha256: 634fff6d442c8040a1025d02e8e28a43edf1f78ce957e49e00970c72e58aa9ef

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

require 'jdbc_common'
require 'db/mssql'

class IgnoreSystemViewsTest < Test::Unit::TestCase

  include MigrationSetup

  def test_system_views_ignored
    if ActiveRecord::Base.connection.sqlserver_version == "2000"
      assert_equal false, table_exists?("sys.views"), %{table_exists?("sys.views")}
      assert_equal false, table_exists?("information_schema.views"), %{table_exists?("information_schema.views")}
    else
      assert_equal true, table_exists?("sys.views"), %{table_exists?("sys.views")}
      assert_equal true, table_exists?("information_schema.views"), %{table_exists?("information_schema.views")}
    end
    assert_equal false, table_exists?("dbo.views"), %{table_exists?("dbo.views")}
    assert_equal false, table_exists?(:views), %{table_exists?(:views)}
    ActiveRecord::Schema.define { suppress_messages { create_table :views } }
    assert_equal true, table_exists?(:views), %{table_exists?(:views)}
    ActiveRecord::Schema.define { suppress_messages { drop_table :views } }
    assert_equal false, table_exists?(:views), %{table_exists?(:views)}
  end

  private

    def table_exists?(*args)
      !!ActiveRecord::Base.connection.table_exists?(*args)
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activerecord-jdbc-adapter-1.2.8 test/mssql_ignore_system_views_test.rb
activerecord-jdbc-adapter-1.2.5 test/mssql_ignore_system_views_test.rb