activerecord-sqlserver-adapter 5.2.0 → 5.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +6 -6
  3. data/CHANGELOG.md +15 -0
  4. data/Dockerfile +1 -1
  5. data/README.md +0 -7
  6. data/VERSION +1 -1
  7. data/lib/active_record/connection_adapters/sqlserver/core_ext/calculations.rb +19 -0
  8. data/lib/active_record/connection_adapters/sqlserver/core_ext/finder_methods.rb +43 -0
  9. data/lib/active_record/connection_adapters/sqlserver/core_ext/query_methods.rb +26 -0
  10. data/lib/active_record/connection_adapters/sqlserver/database_tasks.rb +1 -0
  11. data/lib/active_record/connection_adapters/sqlserver/schema_statements.rb +10 -5
  12. data/lib/active_record/connection_adapters/sqlserver_adapter.rb +6 -2
  13. data/test/cases/adapter_test_sqlserver.rb +18 -18
  14. data/test/cases/change_column_null_test_sqlserver.rb +4 -4
  15. data/test/cases/coerced_tests.rb +28 -9
  16. data/test/cases/column_test_sqlserver.rb +490 -458
  17. data/test/cases/connection_test_sqlserver.rb +2 -2
  18. data/test/cases/fetch_test_sqlserver.rb +5 -5
  19. data/test/cases/helper_sqlserver.rb +5 -0
  20. data/test/cases/json_test_sqlserver.rb +6 -6
  21. data/test/cases/migration_test_sqlserver.rb +10 -2
  22. data/test/cases/pessimistic_locking_test_sqlserver.rb +9 -9
  23. data/test/cases/rake_test_sqlserver.rb +20 -20
  24. data/test/cases/schema_dumper_test_sqlserver.rb +34 -33
  25. data/test/cases/schema_test_sqlserver.rb +2 -2
  26. data/test/cases/showplan_test_sqlserver.rb +14 -14
  27. data/test/cases/specific_schema_test_sqlserver.rb +11 -11
  28. data/test/cases/transaction_test_sqlserver.rb +9 -9
  29. data/test/cases/trigger_test_sqlserver.rb +8 -8
  30. data/test/cases/utils_test_sqlserver.rb +36 -36
  31. data/test/cases/uuid_test_sqlserver.rb +8 -8
  32. data/test/schema/datatypes/2012.sql +1 -0
  33. metadata +5 -5
  34. data/BACKERS.md +0 -32
  35. data/circle.yml +0 -38
@@ -36,7 +36,7 @@ class ConnectionTestSQLServer < ActiveRecord::TestCase
36
36
  describe 'Connection management' do
37
37
 
38
38
  it 'set spid on connect' do
39
- ['Fixnum', 'Integer'].must_include connection.spid.class.name
39
+ _(['Fixnum', 'Integer']).must_include connection.spid.class.name
40
40
  end
41
41
 
42
42
  it 'reset spid on disconnect!' do
@@ -46,7 +46,7 @@ class ConnectionTestSQLServer < ActiveRecord::TestCase
46
46
 
47
47
  it 'reset the connection' do
48
48
  connection.disconnect!
49
- connection.raw_connection.must_be_nil
49
+ _(connection.raw_connection).must_be_nil
50
50
  end
51
51
 
52
52
  it 'be able to disconnect and reconnect at will' do
@@ -36,11 +36,11 @@ class FetchTestSqlserver < ActiveRecord::TestCase
36
36
 
37
37
  it 'gauntlet' do
38
38
  Book.where(name:'Name-10').delete_all
39
- Book.order(:name).limit(1).offset(1).map(&:name).must_equal ['Name-2']
40
- Book.order(:name).limit(2).offset(2).map(&:name).must_equal ['Name-3', 'Name-4']
41
- Book.order(:name).limit(2).offset(7).map(&:name).must_equal ['Name-8', 'Name-9']
42
- Book.order(:name).limit(3).offset(7).map(&:name).must_equal ['Name-8', 'Name-9']
43
- Book.order(:name).limit(3).offset(9).map(&:name).must_equal []
39
+ _(Book.order(:name).limit(1).offset(1).map(&:name)).must_equal ['Name-2']
40
+ _(Book.order(:name).limit(2).offset(2).map(&:name)).must_equal ['Name-3', 'Name-4']
41
+ _(Book.order(:name).limit(2).offset(7).map(&:name)).must_equal ['Name-8', 'Name-9']
42
+ _(Book.order(:name).limit(3).offset(7).map(&:name)).must_equal ['Name-8', 'Name-9']
43
+ _(Book.order(:name).limit(3).offset(9).map(&:name)).must_equal []
44
44
  end
45
45
 
46
46
  end
@@ -25,6 +25,7 @@ module ActiveRecord
25
25
  let(:logger) { ActiveRecord::Base.logger }
26
26
 
27
27
  setup :ensure_clean_rails_env
28
+ setup :remove_backtrace_silencers
28
29
 
29
30
  private
30
31
 
@@ -32,6 +33,10 @@ module ActiveRecord
32
33
  Rails.instance_variable_set(:@_env, nil) if defined?(::Rails)
33
34
  end
34
35
 
36
+ def remove_backtrace_silencers
37
+ Rails.backtrace_cleaner.remove_silencers!
38
+ end
39
+
35
40
  def host_windows?
36
41
  RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
37
42
  end
@@ -12,20 +12,20 @@ class JsonTestSQLServer < ActiveRecord::TestCase
12
12
  end
13
13
 
14
14
  it 'can return and save JSON data' do
15
- SSTestDatatypeMigrationJson.find(@o1.id).json_col.must_equal({ 'a' => 'a', 'b' => 'b', 'c' => 'c' })
15
+ _(SSTestDatatypeMigrationJson.find(@o1.id).json_col).must_equal({ 'a' => 'a', 'b' => 'b', 'c' => 'c' })
16
16
  @o1.json_col = { 'a' => 'a' }
17
- @o1.json_col.must_equal({ 'a' => 'a' })
17
+ _(@o1.json_col).must_equal({ 'a' => 'a' })
18
18
  @o1.save!
19
- @o1.reload.json_col.must_equal({ 'a' => 'a' })
19
+ _(@o1.reload.json_col).must_equal({ 'a' => 'a' })
20
20
  end
21
21
 
22
22
  it 'can use ISJSON function' do
23
- SSTestDatatypeMigrationJson.where('ISJSON(json_col) > 0').count.must_equal 4
24
- SSTestDatatypeMigrationJson.where('ISJSON(json_col) IS NULL').count.must_equal 1
23
+ _(SSTestDatatypeMigrationJson.where('ISJSON(json_col) > 0').count).must_equal 4
24
+ _(SSTestDatatypeMigrationJson.where('ISJSON(json_col) IS NULL').count).must_equal 1
25
25
  end
26
26
 
27
27
  it 'can use JSON_VALUE function' do
28
- SSTestDatatypeMigrationJson.where("JSON_VALUE(json_col, '$.b') = 'b'").count.must_equal 2
28
+ _(SSTestDatatypeMigrationJson.where("JSON_VALUE(json_col, '$.b') = 'b'").count).must_equal 2
29
29
  end
30
30
 
31
31
  end
@@ -24,8 +24,8 @@ class MigrationTestSQLServer < ActiveRecord::TestCase
24
24
  rescue Exception => e
25
25
  assert_match %r|this and all later migrations canceled|, e.message
26
26
  end
27
- connection.tables.wont_include @trans_test_table1
28
- connection.tables.wont_include @trans_test_table2
27
+ _(connection.tables).wont_include @trans_test_table1
28
+ _(connection.tables).wont_include @trans_test_table2
29
29
  end
30
30
 
31
31
  end
@@ -57,6 +57,14 @@ class MigrationTestSQLServer < ActiveRecord::TestCase
57
57
  assert default_after
58
58
  assert_equal default_before['constraint_keys'], default_after['constraint_keys']
59
59
  end
60
+
61
+ it 'change limit' do
62
+ assert_nothing_raised { connection.change_column :people, :lock_version, :integer, limit: 8 }
63
+ end
64
+
65
+ it 'change null and default' do
66
+ assert_nothing_raised { connection.change_column :people, :first_name, :text, null: true, default: nil }
67
+ end
60
68
 
61
69
  end
62
70
 
@@ -13,7 +13,7 @@ class PessimisticLockingTestSQLServer < ActiveRecord::TestCase
13
13
 
14
14
  it 'uses with updlock by default' do
15
15
  assert_sql %r|SELECT \[people\]\.\* FROM \[people\] WITH\(UPDLOCK\)| do
16
- Person.lock(true).to_a.must_equal Person.all.to_a
16
+ _(Person.lock(true).to_a).must_equal Person.all.to_a
17
17
  end
18
18
  end
19
19
 
@@ -22,7 +22,7 @@ class PessimisticLockingTestSQLServer < ActiveRecord::TestCase
22
22
  it 'lock with simple find' do
23
23
  assert_nothing_raised do
24
24
  Person.transaction do
25
- Person.lock(true).find(1).must_equal Person.find(1)
25
+ _(Person.lock(true).find(1)).must_equal Person.find(1)
26
26
  end
27
27
  end
28
28
  end
@@ -31,7 +31,7 @@ class PessimisticLockingTestSQLServer < ActiveRecord::TestCase
31
31
  assert_nothing_raised do
32
32
  Person.transaction do
33
33
  Person.lock(true).scoping do
34
- Person.find(1).must_equal Person.find(1)
34
+ _(Person.find(1)).must_equal Person.find(1)
35
35
  end
36
36
  end
37
37
  end
@@ -41,7 +41,7 @@ class PessimisticLockingTestSQLServer < ActiveRecord::TestCase
41
41
  assert_nothing_raised do
42
42
  Person.transaction do
43
43
  person = Person.lock(true).includes(:readers).find(1)
44
- person.must_equal Person.find(1)
44
+ _(person).must_equal Person.find(1)
45
45
  end
46
46
  end
47
47
  end
@@ -94,11 +94,11 @@ class PessimisticLockingTestSQLServer < ActiveRecord::TestCase
94
94
  loader_sql = /SELECT.*FROM \[people\] WITH\(UPDLOCK\).*WHERE \[people\]\.\[id\] IN/
95
95
  assert_sql(eager_ids_sql, loader_sql) do
96
96
  people = Person.lock(true).limit(5).offset(10).includes(:readers).references(:readers).to_a
97
- people[0].first_name.must_equal 'Thing_10'
98
- people[1].first_name.must_equal 'Thing_11'
99
- people[2].first_name.must_equal 'Thing_12'
100
- people[3].first_name.must_equal 'Thing_13'
101
- people[4].first_name.must_equal 'Thing_14'
97
+ _(people[0].first_name).must_equal 'Thing_10'
98
+ _(people[1].first_name).must_equal 'Thing_11'
99
+ _(people[2].first_name).must_equal 'Thing_12'
100
+ _(people[3].first_name).must_equal 'Thing_13'
101
+ _(people[4].first_name).must_equal 'Thing_14'
102
102
  end
103
103
  end
104
104
 
@@ -43,23 +43,23 @@ class SQLServerRakeCreateTest < SQLServerRakeTest
43
43
 
44
44
  it 'establishes connection to database after create ' do
45
45
  quietly { db_tasks.create configuration }
46
- connection.current_database.must_equal(new_database)
46
+ _(connection.current_database).must_equal(new_database)
47
47
  end
48
48
 
49
49
  it 'creates database with default collation' do
50
50
  quietly { db_tasks.create configuration }
51
- connection.collation.must_equal 'SQL_Latin1_General_CP1_CI_AS'
51
+ _(connection.collation).must_equal 'SQL_Latin1_General_CP1_CI_AS'
52
52
  end
53
53
 
54
54
  it 'creates database with given collation' do
55
55
  quietly { db_tasks.create configuration.merge('collation' => 'Latin1_General_CI_AS') }
56
- connection.collation.must_equal 'Latin1_General_CI_AS'
56
+ _(connection.collation).must_equal 'Latin1_General_CI_AS'
57
57
  end
58
58
 
59
59
  it 'prints error message when database exists' do
60
60
  quietly { db_tasks.create configuration }
61
61
  message = capture(:stderr) { db_tasks.create configuration }
62
- message.must_match %r{activerecord_unittest_tasks.*already exists}
62
+ _(message).must_match %r{activerecord_unittest_tasks.*already exists}
63
63
  end
64
64
 
65
65
  end
@@ -73,12 +73,12 @@ class SQLServerRakeDropTest < SQLServerRakeTest
73
73
  db_tasks.create configuration
74
74
  db_tasks.drop configuration
75
75
  end
76
- connection.current_database.must_equal 'master'
76
+ _(connection.current_database).must_equal 'master'
77
77
  end
78
78
 
79
79
  it 'prints error message when database does not exist' do
80
80
  message = capture(:stderr) { db_tasks.drop configuration.merge('database' => 'doesnotexist') }
81
- message.must_match %r{'doesnotexist' does not exist}
81
+ _(message).must_match %r{'doesnotexist' does not exist}
82
82
  end
83
83
 
84
84
  end
@@ -94,11 +94,11 @@ class SQLServerRakePurgeTest < SQLServerRakeTest
94
94
  end
95
95
 
96
96
  it 'clears active connections, drops database, and recreates with established connection' do
97
- connection.current_database.must_equal(new_database)
98
- connection.tables.must_include 'users'
97
+ _(connection.current_database).must_equal(new_database)
98
+ _(connection.tables).must_include 'users'
99
99
  quietly { db_tasks.purge(configuration) }
100
- connection.current_database.must_equal(new_database)
101
- connection.tables.wont_include 'users'
100
+ _(connection.current_database).must_equal(new_database)
101
+ _(connection.tables).wont_include 'users'
102
102
  end
103
103
 
104
104
  end
@@ -110,7 +110,7 @@ class SQLServerRakeCharsetTest < SQLServerRakeTest
110
110
  end
111
111
 
112
112
  it 'retrieves charset' do
113
- db_tasks.charset(configuration).must_equal 'iso_1'
113
+ _(db_tasks.charset(configuration)).must_equal 'iso_1'
114
114
  end
115
115
 
116
116
  end
@@ -122,7 +122,7 @@ class SQLServerRakeCollationTest < SQLServerRakeTest
122
122
  end
123
123
 
124
124
  it 'retrieves collation' do
125
- db_tasks.collation(configuration).must_equal 'SQL_Latin1_General_CP1_CI_AS'
125
+ _(db_tasks.collation(configuration)).must_equal 'SQL_Latin1_General_CP1_CI_AS'
126
126
  end
127
127
 
128
128
  end
@@ -149,21 +149,21 @@ class SQLServerRakeStructureDumpLoadTest < SQLServerRakeTest
149
149
  it 'dumps structure and accounts for defncopy oddities' do
150
150
  skip 'debug defncopy on windows later' if host_windows?
151
151
  quietly { db_tasks.structure_dump configuration, filename }
152
- filedata.wont_match %r{\AUSE.*\z}
153
- filedata.wont_match %r{\AGO.*\z}
154
- filedata.must_match %r{email\s+nvarchar\(4000\)}
155
- filedata.must_match %r{background1\s+nvarchar\(max\)}
156
- filedata.must_match %r{background2\s+text\s+}
152
+ _(filedata).wont_match %r{\AUSE.*\z}
153
+ _(filedata).wont_match %r{\AGO.*\z}
154
+ _(filedata).must_match %r{email\s+nvarchar\(4000\)}
155
+ _(filedata).must_match %r{background1\s+nvarchar\(max\)}
156
+ _(filedata).must_match %r{background2\s+text\s+}
157
157
  end
158
158
 
159
159
  it 'can load dumped structure' do
160
160
  skip 'debug defncopy on windows later' if host_windows?
161
161
  quietly { db_tasks.structure_dump configuration, filename }
162
- filedata.must_match %r{CREATE TABLE dbo\.users}
162
+ _(filedata).must_match %r{CREATE TABLE dbo\.users}
163
163
  db_tasks.purge(configuration)
164
- connection.tables.wont_include 'users'
164
+ _(connection.tables).wont_include 'users'
165
165
  db_tasks.load_schema configuration, :sql, filename
166
- connection.tables.must_include 'users'
166
+ _(connection.tables).must_include 'users'
167
167
  end
168
168
 
169
169
  end
@@ -34,6 +34,7 @@ class SchemaDumperTestSQLServer < ActiveRecord::TestCase
34
34
  if connection_dblib_73?
35
35
  assert_line :time_7, type: 'time', limit: nil, precision: 7, scale: nil, default: "04:20:00.2883215"
36
36
  assert_line :time_2, type: 'time', limit: nil, precision: 2, scale: nil, default: nil
37
+ assert_line :time_default, type: 'time', limit: nil, precision: 7, scale: nil, default: "15:03:42.0621978"
37
38
  end
38
39
  # Character Strings
39
40
  assert_line :char_10, type: 'char', limit: 10, precision: nil, scale: nil, default: "1234567890", collation: nil
@@ -58,18 +59,18 @@ class SchemaDumperTestSQLServer < ActiveRecord::TestCase
58
59
  columns = SSTestDatatypeMigration.columns_hash
59
60
  generate_schema_for_table 'sst_datatypes_migration'
60
61
  # Simple Rails conventions
61
- columns['integer_col'].sql_type.must_equal 'int(4)'
62
- columns['bigint_col'].sql_type.must_equal 'bigint(8)'
63
- columns['boolean_col'].sql_type.must_equal 'bit'
64
- columns['decimal_col'].sql_type.must_equal 'decimal(18,0)'
65
- columns['float_col'].sql_type.must_equal 'float'
66
- columns['string_col'].sql_type.must_equal 'nvarchar(4000)'
67
- columns['text_col'].sql_type.must_equal 'nvarchar(max)'
68
- columns['datetime_col'].sql_type.must_equal 'datetime'
69
- columns['timestamp_col'].sql_type.must_equal 'datetime'
70
- columns['time_col'].sql_type.must_equal 'time(7)'
71
- columns['date_col'].sql_type.must_equal 'date'
72
- columns['binary_col'].sql_type.must_equal 'varbinary(max)'
62
+ _(columns['integer_col'].sql_type).must_equal 'int(4)'
63
+ _(columns['bigint_col'].sql_type).must_equal 'bigint(8)'
64
+ _(columns['boolean_col'].sql_type).must_equal 'bit'
65
+ _(columns['decimal_col'].sql_type).must_equal 'decimal(18,0)'
66
+ _(columns['float_col'].sql_type).must_equal 'float'
67
+ _(columns['string_col'].sql_type).must_equal 'nvarchar(4000)'
68
+ _(columns['text_col'].sql_type).must_equal 'nvarchar(max)'
69
+ _(columns['datetime_col'].sql_type).must_equal 'datetime'
70
+ _(columns['timestamp_col'].sql_type).must_equal 'datetime'
71
+ _(columns['time_col'].sql_type).must_equal 'time(7)'
72
+ _(columns['date_col'].sql_type).must_equal 'date'
73
+ _(columns['binary_col'].sql_type).must_equal 'varbinary(max)'
73
74
  assert_line :integer_col, type: 'integer', limit: nil, precision: nil, scale: nil, default: nil
74
75
  assert_line :bigint_col, type: 'bigint', limit: nil, precision: nil, scale: nil, default: nil
75
76
  assert_line :boolean_col, type: 'boolean', limit: nil, precision: nil, scale: nil, default: nil
@@ -83,22 +84,22 @@ class SchemaDumperTestSQLServer < ActiveRecord::TestCase
83
84
  assert_line :date_col, type: 'date', limit: nil, precision: nil, scale: nil, default: nil
84
85
  assert_line :binary_col, type: 'binary', limit: nil, precision: nil, scale: nil, default: nil
85
86
  # Our type methods.
86
- columns['real_col'].sql_type.must_equal 'real'
87
- columns['money_col'].sql_type.must_equal 'money'
88
- columns['smalldatetime_col'].sql_type.must_equal 'smalldatetime'
89
- columns['datetime2_col'].sql_type.must_equal 'datetime2(7)'
90
- columns['datetimeoffset'].sql_type.must_equal 'datetimeoffset(7)'
91
- columns['smallmoney_col'].sql_type.must_equal 'smallmoney'
92
- columns['char_col'].sql_type.must_equal 'char(1)'
93
- columns['varchar_col'].sql_type.must_equal 'varchar(8000)'
94
- columns['text_basic_col'].sql_type.must_equal 'text'
95
- columns['nchar_col'].sql_type.must_equal 'nchar(1)'
96
- columns['ntext_col'].sql_type.must_equal 'ntext'
97
- columns['binary_basic_col'].sql_type.must_equal 'binary(1)'
98
- columns['varbinary_col'].sql_type.must_equal 'varbinary(8000)'
99
- columns['uuid_col'].sql_type.must_equal 'uniqueidentifier'
100
- columns['sstimestamp_col'].sql_type.must_equal 'timestamp'
101
- columns['json_col'].sql_type.must_equal 'nvarchar(max)'
87
+ _(columns['real_col'].sql_type).must_equal 'real'
88
+ _(columns['money_col'].sql_type).must_equal 'money'
89
+ _(columns['smalldatetime_col'].sql_type).must_equal 'smalldatetime'
90
+ _(columns['datetime2_col'].sql_type).must_equal 'datetime2(7)'
91
+ _(columns['datetimeoffset'].sql_type).must_equal 'datetimeoffset(7)'
92
+ _(columns['smallmoney_col'].sql_type).must_equal 'smallmoney'
93
+ _(columns['char_col'].sql_type).must_equal 'char(1)'
94
+ _(columns['varchar_col'].sql_type).must_equal 'varchar(8000)'
95
+ _(columns['text_basic_col'].sql_type).must_equal 'text'
96
+ _(columns['nchar_col'].sql_type).must_equal 'nchar(1)'
97
+ _(columns['ntext_col'].sql_type).must_equal 'ntext'
98
+ _(columns['binary_basic_col'].sql_type).must_equal 'binary(1)'
99
+ _(columns['varbinary_col'].sql_type).must_equal 'varbinary(8000)'
100
+ _(columns['uuid_col'].sql_type).must_equal 'uniqueidentifier'
101
+ _(columns['sstimestamp_col'].sql_type).must_equal 'timestamp'
102
+ _(columns['json_col'].sql_type).must_equal 'nvarchar(max)'
102
103
  assert_line :real_col, type: 'real', limit: nil, precision: nil, scale: nil, default: nil
103
104
  assert_line :money_col, type: 'money', limit: nil, precision: 19, scale: 4, default: nil
104
105
  assert_line :smalldatetime_col, type: 'smalldatetime', limit: nil, precision: nil, scale: nil, default: nil
@@ -129,7 +130,7 @@ class SchemaDumperTestSQLServer < ActiveRecord::TestCase
129
130
 
130
131
  it 'no id with model driven primary key' do
131
132
  output = generate_schema_for_table 'sst_no_pk_data'
132
- output.must_match %r{create_table "sst_no_pk_data".*id:\sfalse.*do}
133
+ _(output).must_match %r{create_table "sst_no_pk_data".*id:\sfalse.*do}
133
134
  assert_line :name, type: 'string', limit: nil, default: nil, collation: nil
134
135
  end
135
136
 
@@ -165,15 +166,15 @@ class SchemaDumperTestSQLServer < ActiveRecord::TestCase
165
166
  expected = options[key]
166
167
  message = "#{key.to_s.titleize} of #{expected.inspect} not found in:\n#{line}"
167
168
  if expected.nil?
168
- actual.must_be_nil message
169
+ _(actual).must_be_nil message
169
170
  elsif expected.is_a?(Array)
170
171
  actual.must_include expected, message
171
172
  elsif expected.is_a?(Float)
172
- actual.must_be_close_to expected, 0.001
173
+ _(actual).must_be_close_to expected, 0.001
173
174
  elsif expected.is_a?(Proc)
174
- actual.call.must_equal(expected.call)
175
+ _(actual.call).must_equal(expected.call)
175
176
  else
176
- actual.must_equal expected, message
177
+ _(actual).must_equal expected, message
177
178
  end
178
179
  end
179
180
  end
@@ -5,7 +5,7 @@ class SchemaTestSQLServer < ActiveRecord::TestCase
5
5
  describe 'When table is dbo schema' do
6
6
 
7
7
  it 'find primary key for tables with odd schema' do
8
- connection.primary_key('sst_natural_pk_data').must_equal 'legacy_id'
8
+ _(connection.primary_key('sst_natural_pk_data')).must_equal 'legacy_id'
9
9
  end
10
10
 
11
11
  end
@@ -18,7 +18,7 @@ class SchemaTestSQLServer < ActiveRecord::TestCase
18
18
  end
19
19
 
20
20
  it 'find primary key for tables with odd schema' do
21
- connection.primary_key('test.sst_schema_natural_id').must_equal 'legacy_id'
21
+ _(connection.primary_key('test.sst_schema_natural_id')).must_equal 'legacy_id'
22
22
  end
23
23
 
24
24
  it "have only one identity column" do
@@ -9,33 +9,33 @@ class ShowplanTestSQLServer < ActiveRecord::TestCase
9
9
 
10
10
  it 'from simple statement' do
11
11
  plan = Car.where(id: 1).explain
12
- plan.must_include "SELECT [cars].* FROM [cars] WHERE [cars].[id] = 1"
13
- plan.must_include "Clustered Index Seek", 'make sure we do not showplan the sp_executesql'
12
+ _(plan).must_include "SELECT [cars].* FROM [cars] WHERE [cars].[id] = 1"
13
+ _(plan).must_include "Clustered Index Seek", 'make sure we do not showplan the sp_executesql'
14
14
  end
15
15
 
16
16
  it 'from multiline statement' do
17
17
  plan = Car.where("\n id = 1 \n").explain
18
- plan.must_include "SELECT [cars].* FROM [cars] WHERE (\n id = 1 \n)"
19
- plan.must_include "Clustered Index Seek", 'make sure we do not showplan the sp_executesql'
18
+ _(plan).must_include "SELECT [cars].* FROM [cars] WHERE (\n id = 1 \n)"
19
+ _(plan).must_include "Clustered Index Seek", 'make sure we do not showplan the sp_executesql'
20
20
  end
21
21
 
22
22
  it 'from prepared statement' do
23
23
  plan = Car.where(name: ',').limit(1).explain
24
- plan.must_include " SELECT [cars].* FROM [cars] WHERE [cars].[name]"
25
- plan.must_include "TOP EXPRESSION", 'make sure we do not showplan the sp_executesql'
26
- plan.must_include "Clustered Index Scan", 'make sure we do not showplan the sp_executesql'
24
+ _(plan).must_include " SELECT [cars].* FROM [cars] WHERE [cars].[name]"
25
+ _(plan).must_include "TOP EXPRESSION", 'make sure we do not showplan the sp_executesql'
26
+ _(plan).must_include "Clustered Index Scan", 'make sure we do not showplan the sp_executesql'
27
27
  end
28
28
 
29
29
  it 'from array condition using index' do
30
30
  plan = Car.where(id: [1, 2]).explain
31
- plan.must_include " SELECT [cars].* FROM [cars] WHERE [cars].[id] IN (1, 2)"
32
- plan.must_include "Clustered Index Seek", 'make sure we do not showplan the sp_executesql'
31
+ _(plan).must_include " SELECT [cars].* FROM [cars] WHERE [cars].[id] IN (1, 2)"
32
+ _(plan).must_include "Clustered Index Seek", 'make sure we do not showplan the sp_executesql'
33
33
  end
34
34
 
35
35
  it 'from array condition' do
36
36
  plan = Car.where(name: ['honda', 'zyke']).explain
37
- plan.must_include " SELECT [cars].* FROM [cars] WHERE [cars].[name] IN (N'honda', N'zyke')"
38
- plan.must_include "Clustered Index Scan", 'make sure we do not showplan the sp_executesql'
37
+ _(plan).must_include " SELECT [cars].* FROM [cars] WHERE [cars].[name] IN (N'honda', N'zyke')"
38
+ _(plan).must_include "Clustered Index Scan", 'make sure we do not showplan the sp_executesql'
39
39
  end
40
40
 
41
41
  end
@@ -45,8 +45,8 @@ class ShowplanTestSQLServer < ActiveRecord::TestCase
45
45
  it 'use simple table printer' do
46
46
  with_showplan_option('SHOWPLAN_TEXT') do
47
47
  plan = Car.where(id: 1).explain
48
- plan.must_include "SELECT [cars].* FROM [cars] WHERE [cars].[id]"
49
- plan.must_include "Clustered Index Seek", 'make sure we do not showplan the sp_executesql'
48
+ _(plan).must_include "SELECT [cars].* FROM [cars] WHERE [cars].[id]"
49
+ _(plan).must_include "Clustered Index Seek", 'make sure we do not showplan the sp_executesql'
50
50
  end
51
51
  end
52
52
 
@@ -57,7 +57,7 @@ class ShowplanTestSQLServer < ActiveRecord::TestCase
57
57
  it 'show formatted xml' do
58
58
  with_showplan_option('SHOWPLAN_XML') do
59
59
  plan = Car.where(id: 1).explain
60
- plan.must_include 'ShowPlanXML'
60
+ _(plan).must_include 'ShowPlanXML'
61
61
  end
62
62
  end
63
63