Skip to content

Commit ec20a9d

Browse files
committed
[mssql] test fix + due Java API refactorings #tables/#table_exists? changed
and it's probably fine that #table_exists? reports views as well - their only filtered out from #tables ... this is how most native adapters work as well
1 parent a5ae532 commit ec20a9d

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

test/db/mssql/ignore_system_views_test.rb

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,33 @@ class MSSQLIgnoreSystemViewsTest < Test::Unit::TestCase
55
include MigrationSetup
66

77
def test_system_views_ignored
8+
assert_not_include tables, 'views'
89
if ActiveRecord::Base.connection.sqlserver_version == "2000"
9-
assert_equal false, table_exists?("sys.views"), %{table_exists?("sys.views")}
10-
assert_equal false, table_exists?("information_schema.views"), %{table_exists?("information_schema.views")}
10+
assert_false table_exists?("sys.views"), %{table_exists?("sys.views")}
11+
assert_false table_exists?("information_schema.views"), %{table_exists?("information_schema.views")}
1112
else
12-
assert_equal true, table_exists?("sys.views"), %{table_exists?("sys.views")}
13-
assert_equal true, table_exists?("information_schema.views"), %{table_exists?("information_schema.views")}
13+
assert_true table_exists?("sys.views"), %{table_exists?("sys.views")}
14+
assert_true table_exists?("information_schema.views"), %{table_exists?("information_schema.views")}
15+
16+
assert_true table_exists?(:views), %{table_exists?(:views)}
1417
end
15-
assert_equal false, table_exists?("dbo.views"), %{table_exists?("dbo.views")}
16-
assert_equal false, table_exists?(:views), %{table_exists?(:views)}
18+
assert_false table_exists?("dbo.views"), %{table_exists?("dbo.views")}
19+
#assert_false table_exists?(:views), %{table_exists?(:views)}
1720
ActiveRecord::Schema.define { suppress_messages { create_table :views } }
18-
assert_equal true, table_exists?(:views), %{table_exists?(:views)}
21+
assert_include tables, 'views'
22+
assert_true table_exists?(:views), %{table_exists?(:views)}
1923
ActiveRecord::Schema.define { suppress_messages { drop_table :views } }
20-
assert_equal false, table_exists?(:views), %{table_exists?(:views)}
24+
#assert_false table_exists?(:views), %{table_exists?(:views)}
25+
ensure
26+
ActiveRecord::Base.connection.drop_table(:views) rescue nil
2127
end
2228

2329
private
2430

31+
def tables
32+
ActiveRecord::Base.connection.tables
33+
end
34+
2535
def table_exists?(*args)
2636
ActiveRecord::Base.connection.table_exists?(*args)
2737
end

test/db/mssql/simple_test.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ def test_change_column_nullability
5555

5656
# ACTIVERECORD_JDBC-124
5757
def test_model_does_not_have_row_num_column
58-
entry = Entry.first
59-
assert_false entry.attributes.keys.include?("_row_num")
60-
assert_false entry.respond_to?(:_row_num)
58+
User.create! :login => 'row_num'
59+
model = User.first
60+
assert_false model.attributes.keys.include?("_row_num")
61+
assert_false model.respond_to?(:_row_num)
6162
end
6263

6364
def test_returns_charset

0 commit comments

Comments
 (0)