activerecord-sqlserver-adapter 5.2.0 → 5.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a148546b3f7d4e6734c8c8a7d834c242a7e1cec5344601d527f0c567cd6ad2e1
4
- data.tar.gz: 261bd21097b324059eb205960c73c1eb3f1c8d4cb9a6da7c91876d64d33f8381
3
+ metadata.gz: 5c31b843cb8193ccc2c2777a80e658c3b7675c3ea5387f78f3b4b1316b96dd00
4
+ data.tar.gz: ab77e8f296d0eb35877a34f5a0d31fa1da51f69e09bb852db6b97ced8c133f04
5
5
  SHA512:
6
- metadata.gz: ed85ad0fb65a3e32312c10db899037786549abe289e5cfeb519634d0a4e090a39c4c193b89e8285ba3d3a786c68e4c317440e94e217cb256a109c68b8497fb3d
7
- data.tar.gz: 49f1e9767c1c411e9a86ff8678bc5ac6470d31bead60dba3ca6039fd2fb2a8435ed4c1dda6e59b9745ba4c32ea46166c28907cfce84614aaa64aae080214db5b
6
+ metadata.gz: 11d4df1451f076a4877e09698a9696355f16d2b958ef0fb19f353217211c0871645736c40ab2300bfba7f6e7fcac994b918de927dfef40db66cca2500dd43b5a
7
+ data.tar.gz: cecaad6271fb78bb6ace828f7e16bd67007c0ae5e55f6759c49c710f5cb02dbe361f9a06bf9159599b36cf1c6325c0e631670cf30dca519447145d0bee62823e
@@ -17,9 +17,9 @@ matrix:
17
17
  include:
18
18
  - name: 2.3.8
19
19
  env: TARGET_VERSION=2.3.8
20
- - name: 2.4.5
21
- env: TARGET_VERSION=2.4.5
22
- - name: 2.5.3
23
- env: TARGET_VERSION=2.5.3
24
- - name: 2.6.0
25
- env: TARGET_VERSION=2.6.0
20
+ - name: 2.4.6
21
+ env: TARGET_VERSION=2.4.6
22
+ - name: 2.5.5
23
+ env: TARGET_VERSION=2.5.5
24
+ - name: 2.6.3
25
+ env: TARGET_VERSION=2.6.3
@@ -1,5 +1,20 @@
1
+ ## v5.2.1
2
+
3
+ #### Fixed
4
+
5
+ - #691 Fix constraints bug
6
+ - #700 SET SINGLE_USER before dropping the database
7
+ - #733 Calculate should not remove ordering for MSSQL
8
+ - #735 Order by selected items when using distinct exists
9
+ - #737 Use default precision for 'time' column type
10
+ - #744 Adapter does not use prepared statement cache
11
+ - #743 Set default time precision when registering time type
12
+ - #745 Quoted table names containing square brackets need to be regex escaped
13
+
1
14
  ## v5.2.0
2
15
 
16
+ #### Fixed
17
+
3
18
  - #686 sql_for_insert set table name in case when pk is not nil
4
19
 
5
20
  ## v5.2.0.rc2
data/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- ARG TARGET_VERSION=2.5.3
1
+ ARG TARGET_VERSION=2.6.3
2
2
 
3
3
  FROM wpolicarpo/activerecord-sqlserver-adapter:${TARGET_VERSION}
4
4
 
data/README.md CHANGED
@@ -1,17 +1,10 @@
1
1
  # ActiveRecord SQL Server Adapter. For SQL Server 2012 And Higher.
2
2
 
3
3
  * [![TravisCI](https://travis-ci.org/rails-sqlserver/activerecord-sqlserver-adapter.svg?branch=master)](https://travis-ci.org/rails-sqlserver/activerecord-sqlserver-adapter) - TravisCI
4
- * [![CircleCI](https://circleci.com/gh/rails-sqlserver/activerecord-sqlserver-adapter/tree/master.svg?style=svg)](https://circleci.com/gh/rails-sqlserver/activerecord-sqlserver-adapter/tree/master) - CircleCI
5
4
  * [![Build Status](https://ci.appveyor.com/api/projects/status/mtgbx8f57vr7k2qa/branch/master?svg=true)](https://ci.appveyor.com/project/rails-sqlserver/activerecord-sqlserver-adapter/branch/master) - Appveyor
6
5
  * [![Gem Version](http://img.shields.io/gem/v/activerecord-sqlserver-adapter.svg)](https://rubygems.org/gems/activerecord-sqlserver-adapter) - Gem Version
7
- * [![Dependency Status](https://dependencyci.com/github/rails-sqlserver/activerecord-sqlserver-adapter/badge)](https://dependencyci.com/github/rails-sqlserver/activerecord-sqlserver-adapter) - Dependency Status
8
6
  * [![Gitter chat](https://img.shields.io/badge/%E2%8A%AA%20GITTER%20-JOIN%20CHAT%20%E2%86%92-brightgreen.svg?style=flat)](https://gitter.im/rails-sqlserver/activerecord-sqlserver-adapter) - Community
9
7
 
10
- ## Supporting TinyTDS/Adapter
11
-
12
- Both TinyTDS and the Rails SQL Server Adapter are MIT-licensed open source projects. Its ongoing development is made possible thanks to the support by these awesome [backers](https://github.com/rails-sqlserver/tiny_tds/blob/master/BACKERS.md). If you'd like to join them, check out our [Patreon Campaign](https://www.patreon.com/metaskills).
13
-
14
-
15
8
  ## About The Adapter
16
9
 
17
10
  The SQL Server adapter for ActiveRecord v5.2 using SQL Server 2012 or higher.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.2.0
1
+ 5.2.1
@@ -6,6 +6,25 @@ module ActiveRecord
6
6
  module SQLServer
7
7
  module CoreExt
8
8
  module Calculations
9
+
10
+ # Same as original except we don't perform PostgreSQL hack that removes ordering.
11
+ def calculate(operation, column_name)
12
+ if has_include?(column_name)
13
+ relation = apply_join_dependency
14
+
15
+ if operation.to_s.downcase == "count"
16
+ unless distinct_value || distinct_select?(column_name || select_for_count)
17
+ relation.distinct!
18
+ relation.select_values = [ klass.primary_key || table[Arel.star] ]
19
+ end
20
+ end
21
+
22
+ relation.calculate(operation, column_name)
23
+ else
24
+ perform_calculation(operation, column_name)
25
+ end
26
+ end
27
+
9
28
  private
10
29
 
11
30
  def build_count_subquery(relation, column_name, distinct)
@@ -0,0 +1,43 @@
1
+ require 'active_record/relation'
2
+ require 'active_record/version'
3
+
4
+ module ActiveRecord
5
+ module ConnectionAdapters
6
+ module SQLServer
7
+ module CoreExt
8
+ module FinderMethods
9
+
10
+ private
11
+
12
+ # Same as original except we order by values in distinct select if present.
13
+ def construct_relation_for_exists(conditions)
14
+ if distinct_value && offset_value
15
+ relation = limit!(1)
16
+
17
+ if select_values.present?
18
+ relation = relation.order(*select_values)
19
+ else
20
+ relation = relation.except(:order)
21
+ end
22
+ else
23
+ relation = except(:select, :distinct, :order)._select!(::ActiveRecord::FinderMethods::ONE_AS_ONE).limit!(1)
24
+ end
25
+
26
+ case conditions
27
+ when Array, Hash
28
+ relation.where!(conditions) unless conditions.empty?
29
+ else
30
+ relation.where!(primary_key => conditions) unless conditions == :none
31
+ end
32
+
33
+ relation
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ ActiveSupport.on_load(:active_record) do
42
+ ActiveRecord::Relation.include(ActiveRecord::ConnectionAdapters::SQLServer::CoreExt::FinderMethods)
43
+ end
@@ -0,0 +1,26 @@
1
+ require 'active_record/relation'
2
+ require 'active_record/version'
3
+
4
+ module ActiveRecord
5
+ module ConnectionAdapters
6
+ module SQLServer
7
+ module CoreExt
8
+ module QueryMethods
9
+
10
+ private
11
+
12
+ # Copy of original from Rails master. This patch can be removed when adapter supports Rails 6.
13
+ def table_name_matches?(from)
14
+ table_name = Regexp.escape(table.name)
15
+ quoted_table_name = Regexp.escape(connection.quote_table_name(table.name))
16
+ /(?:\A|(?<!FROM)\s)(?:\b#{table_name}\b|#{quoted_table_name})(?!\.)/i.match?(from.to_s)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ ActiveSupport.on_load(:active_record) do
25
+ ActiveRecord::Relation.include(ActiveRecord::ConnectionAdapters::SQLServer::CoreExt::QueryMethods)
26
+ end
@@ -12,6 +12,7 @@ module ActiveRecord
12
12
 
13
13
  def drop_database(database)
14
14
  name = SQLServer::Utils.extract_identifiers(database)
15
+ do_execute "ALTER DATABASE #{name} SET SINGLE_USER WITH ROLLBACK IMMEDIATE"
15
16
  do_execute "DROP DATABASE #{name}"
16
17
  end
17
18
 
@@ -141,7 +141,13 @@ module ActiveRecord
141
141
  sql_commands = []
142
142
  indexes = []
143
143
  column_object = schema_cache.columns(table_name).find { |c| c.name.to_s == column_name.to_s }
144
- if options_include_default?(options) || (column_object && column_object.type != type.to_sym)
144
+ without_constraints = options.key?(:default) || options.key?(:limit)
145
+ default = if !options.key?(:default) && column_object
146
+ column_object.default
147
+ else
148
+ options[:default]
149
+ end
150
+ if without_constraints || (column_object && column_object.type != type.to_sym)
145
151
  remove_default_constraint(table_name, column_name)
146
152
  indexes = indexes(table_name).select { |index| index.columns.include?(column_name.to_s) }
147
153
  remove_indexes(table_name, column_name)
@@ -149,10 +155,9 @@ module ActiveRecord
149
155
  sql_commands << "UPDATE #{quote_table_name(table_name)} SET #{quote_column_name(column_name)}=#{quote_default_expression(options[:default], column_object)} WHERE #{quote_column_name(column_name)} IS NULL" if !options[:null].nil? && options[:null] == false && !options[:default].nil?
150
156
  sql_commands << "ALTER TABLE #{quote_table_name(table_name)} ALTER COLUMN #{quote_column_name(column_name)} #{type_to_sql(type, limit: options[:limit], precision: options[:precision], scale: options[:scale])}"
151
157
  sql_commands.last << ' NOT NULL' if !options[:null].nil? && options[:null] == false
152
- if options.key?(:default) && default_constraint_name(table_name, column_name).present?
153
- change_column_default(table_name, column_name, options[:default])
154
- elsif options_include_default?(options)
155
- sql_commands << "ALTER TABLE #{quote_table_name(table_name)} ADD CONSTRAINT #{default_constraint_name(table_name, column_name)} DEFAULT #{quote_default_expression(options[:default], column_object)} FOR #{quote_column_name(column_name)}"
158
+ if without_constraints
159
+ default = quote_default_expression(default, column_object || column_for(table_name, column_name))
160
+ sql_commands << "ALTER TABLE #{quote_table_name(table_name)} ADD CONSTRAINT #{default_constraint_name(table_name, column_name)} DEFAULT #{default} FOR #{quote_column_name(column_name)}"
156
161
  end
157
162
  # Add any removed indexes back
158
163
  indexes.each do |index|
@@ -7,6 +7,8 @@ require 'active_record/connection_adapters/sqlserver/core_ext/calculations'
7
7
  require 'active_record/connection_adapters/sqlserver/core_ext/explain'
8
8
  require 'active_record/connection_adapters/sqlserver/core_ext/explain_subscriber'
9
9
  require 'active_record/connection_adapters/sqlserver/core_ext/attribute_methods'
10
+ require 'active_record/connection_adapters/sqlserver/core_ext/finder_methods'
11
+ require 'active_record/connection_adapters/sqlserver/core_ext/query_methods'
10
12
  require 'active_record/connection_adapters/sqlserver/version'
11
13
  require 'active_record/connection_adapters/sqlserver/type'
12
14
  require 'active_record/connection_adapters/sqlserver/database_limits'
@@ -40,6 +42,9 @@ module ActiveRecord
40
42
 
41
43
  ADAPTER_NAME = 'SQLServer'.freeze
42
44
 
45
+ # Default precision for 'time' (See https://docs.microsoft.com/en-us/sql/t-sql/data-types/time-transact-sql)
46
+ DEFAULT_TIME_PRECISION = 7
47
+
43
48
  attr_reader :spid
44
49
 
45
50
  cattr_accessor :cs_equality_operator, instance_accessor: false
@@ -296,8 +301,7 @@ module ActiveRecord
296
301
  end
297
302
  m.register_type 'smalldatetime', SQLServer::Type::SmallDateTime.new
298
303
  m.register_type %r{\Atime}i do |sql_type|
299
- scale = extract_scale(sql_type)
300
- precision = extract_precision(sql_type)
304
+ precision = extract_precision(sql_type) || DEFAULT_TIME_PRECISION
301
305
  SQLServer::Type::Time.new precision: precision
302
306
  end
303
307
  # Character Strings
@@ -15,14 +15,14 @@ class AdapterTestSQLServer < ActiveRecord::TestCase
15
15
 
16
16
  it 'has basic and non-senstive information in the adpaters inspect method' do
17
17
  string = connection.inspect
18
- string.must_match %r{ActiveRecord::ConnectionAdapters::SQLServerAdapter}
19
- string.must_match %r{version\: \d.\d}
20
- string.must_match %r{mode: dblib}
21
- string.must_match %r{azure: (true|false)}
22
- string.wont_match %r{host}
23
- string.wont_match %r{password}
24
- string.wont_match %r{username}
25
- string.wont_match %r{port}
18
+ _(string).must_match %r{ActiveRecord::ConnectionAdapters::SQLServerAdapter}
19
+ _(string).must_match %r{version\: \d.\d}
20
+ _(string).must_match %r{mode: dblib}
21
+ _(string).must_match %r{azure: (true|false)}
22
+ _(string).wont_match %r{host}
23
+ _(string).wont_match %r{password}
24
+ _(string).wont_match %r{username}
25
+ _(string).wont_match %r{port}
26
26
  end
27
27
 
28
28
  it 'has a 128 max #table_alias_length' do
@@ -161,7 +161,7 @@ class AdapterTestSQLServer < ActiveRecord::TestCase
161
161
  end
162
162
 
163
163
  it 'return an empty array when calling #identity_columns for a table_name with no identity' do
164
- connection.send(:identity_columns, Subscriber.table_name).must_equal []
164
+ _(connection.send(:identity_columns, Subscriber.table_name)).must_equal []
165
165
  end
166
166
 
167
167
  end
@@ -303,7 +303,7 @@ class AdapterTestSQLServer < ActiveRecord::TestCase
303
303
  end
304
304
 
305
305
  it 'find SSTestCustomersView table name' do
306
- connection.views.must_include 'sst_customers_view'
306
+ _(connection.views).must_include 'sst_customers_view'
307
307
  end
308
308
 
309
309
  it 'work with dynamic finders' do
@@ -344,9 +344,9 @@ class AdapterTestSQLServer < ActiveRecord::TestCase
344
344
  end
345
345
 
346
346
  it 'find identity column' do
347
- SSTestCustomersView.primary_key.must_equal 'id'
348
- connection.primary_key(SSTestCustomersView.table_name).must_equal 'id'
349
- SSTestCustomersView.columns_hash['id'].must_be :is_identity?
347
+ _(SSTestCustomersView.primary_key).must_equal 'id'
348
+ _(connection.primary_key(SSTestCustomersView.table_name)).must_equal 'id'
349
+ _(SSTestCustomersView.columns_hash['id']).must_be :is_identity?
350
350
  end
351
351
 
352
352
  it 'find default values' do
@@ -371,9 +371,9 @@ class AdapterTestSQLServer < ActiveRecord::TestCase
371
371
  end
372
372
 
373
373
  it 'find identity column' do
374
- SSTestStringDefaultsView.primary_key.must_equal 'id'
375
- connection.primary_key(SSTestStringDefaultsView.table_name).must_equal 'id'
376
- SSTestStringDefaultsView.columns_hash['id'].must_be :is_identity?
374
+ _(SSTestStringDefaultsView.primary_key).must_equal 'id'
375
+ _(connection.primary_key(SSTestStringDefaultsView.table_name)).must_equal 'id'
376
+ _(SSTestStringDefaultsView.columns_hash['id']).must_be :is_identity?
377
377
  end
378
378
 
379
379
  it 'find default values' do
@@ -422,8 +422,8 @@ class AdapterTestSQLServer < ActiveRecord::TestCase
422
422
 
423
423
  it 'in_memory_oltp' do
424
424
  if ENV['IN_MEMORY_OLTP'] && connection.supports_in_memory_oltp?
425
- SSTMemory.primary_key.must_equal 'id'
426
- SSTMemory.columns_hash['id'].must_be :is_identity?
425
+ _(SSTMemory.primary_key).must_equal 'id'
426
+ _(SSTMemory.columns_hash['id']).must_be :is_identity?
427
427
  else
428
428
  skip 'supports_in_memory_oltp? => false'
429
429
  end
@@ -24,19 +24,19 @@ class ChangeColumnNullTestSqlServer < ActiveRecord::TestCase
24
24
 
25
25
  describe '#change_column_null' do
26
26
  it 'does not change the column limit' do
27
- name_column.limit.must_equal 15
27
+ _(name_column.limit).must_equal 15
28
28
  end
29
29
 
30
30
  it 'does not change the column default' do
31
- code_column.default.must_equal 'n/a'
31
+ _(code_column.default).must_equal 'n/a'
32
32
  end
33
33
 
34
34
  it 'does not change the column precision' do
35
- value_column.precision.must_equal 32
35
+ _(value_column.precision).must_equal 32
36
36
  end
37
37
 
38
38
  it 'does not change the column scale' do
39
- value_column.scale.must_equal 8
39
+ _(value_column.scale).must_equal 8
40
40
  end
41
41
  end
42
42
  end
@@ -145,8 +145,27 @@ end
145
145
 
146
146
  module ActiveRecord
147
147
  class BindParameterTest < ActiveRecord::TestCase
148
- # Never finds `sql` since we use `EXEC sp_executesql` wrappers.
148
+ # Same as original coerced test except log is found using `EXEC sp_executesql` wrapper.
149
149
  coerce_tests! :test_binds_are_logged
150
+ def test_binds_are_logged_coerced
151
+ sub = Arel::Nodes::BindParam.new(1)
152
+ binds = [Relation::QueryAttribute.new("id", 1, Type::Value.new)]
153
+ sql = "select * from topics where id = #{sub.to_sql}"
154
+
155
+ @connection.exec_query(sql, "SQL", binds)
156
+
157
+ logged_sql = "EXEC sp_executesql N'#{sql}', N'#{sub.to_sql} int', #{sub.to_sql} = 1"
158
+ message = @subscriber.calls.find { |args| args[4][:sql] == logged_sql }
159
+
160
+ assert_equal binds, message[4][:binds]
161
+ end
162
+
163
+ # SQL Server adapter does not use a statement cache as query plans are already reused using `EXEC sp_executesql`.
164
+ coerce_tests! :test_statement_cache
165
+ coerce_tests! :test_statement_cache_with_query_cache
166
+ coerce_tests! :test_statement_cache_with_find_by
167
+ coerce_tests! :test_statement_cache_with_in_clause
168
+ coerce_tests! :test_statement_cache_with_sql_string_literal
150
169
  end
151
170
  end
152
171
 
@@ -192,14 +211,14 @@ class CalculationsTest < ActiveRecord::TestCase
192
211
  def test_limit_is_kept_coerced
193
212
  queries = capture_sql_ss { Account.limit(1).count }
194
213
  assert_equal 1, queries.length
195
- queries.first.must_match %r{ORDER BY \[accounts\]\.\[id\] ASC OFFSET 0 ROWS FETCH NEXT @0 ROWS ONLY.*@0 = 1}
214
+ _(queries.first).must_match %r{ORDER BY \[accounts\]\.\[id\] ASC OFFSET 0 ROWS FETCH NEXT @0 ROWS ONLY.*@0 = 1}
196
215
  end
197
216
 
198
217
  coerce_tests! :test_limit_with_offset_is_kept
199
218
  def test_limit_with_offset_is_kept_coerced
200
219
  queries = capture_sql_ss { Account.limit(1).offset(1).count }
201
220
  assert_equal 1, queries.length
202
- queries.first.must_match %r{ORDER BY \[accounts\]\.\[id\] ASC OFFSET @0 ROWS FETCH NEXT @1 ROWS ONLY.*@0 = 1, @1 = 1}
221
+ _(queries.first).must_match %r{ORDER BY \[accounts\]\.\[id\] ASC OFFSET @0 ROWS FETCH NEXT @1 ROWS ONLY.*@0 = 1, @1 = 1}
203
222
  end
204
223
 
205
224
  # SQL Server needs an alias for the calculated column
@@ -265,7 +284,7 @@ module ActiveRecord
265
284
  def test_add_column_without_limit_coerced
266
285
  add_column :test_models, :description, :string, limit: nil
267
286
  TestModel.reset_column_information
268
- TestModel.columns_hash["description"].limit.must_equal 4000
287
+ _(TestModel.columns_hash["description"].limit).must_equal 4000
269
288
  end
270
289
  end
271
290
  end
@@ -615,14 +634,14 @@ class PersistenceTest < ActiveRecord::TestCase
615
634
  coerce_tests! :test_update_all_doesnt_ignore_order
616
635
  def test_update_all_doesnt_ignore_order_coerced
617
636
  david, mary = authors(:david), authors(:mary)
618
- david.id.must_equal 1
619
- mary.id.must_equal 2
620
- david.name.wont_equal mary.name
637
+ _(david.id).must_equal 1
638
+ _(mary.id).must_equal 2
639
+ _(david.name).wont_equal mary.name
621
640
  assert_sql(/UPDATE.*\(SELECT \[authors\].\[id\] FROM \[authors\].*ORDER BY \[authors\].\[id\]/i) do
622
641
  Author.where('[id] > 1').order(:id).update_all(name: 'Test')
623
642
  end
624
- david.reload.name.must_equal 'David'
625
- mary.reload.name.must_equal 'Test'
643
+ _(david.reload.name).must_equal 'David'
644
+ _(mary.reload.name).must_equal 'Test'
626
645
  end
627
646
 
628
647
  # We can not UPDATE identity columns.
@@ -18,9 +18,9 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
18
18
  def column(name) ; SSTestDatatype.columns_hash[name] ; end
19
19
  def assert_obj_set_and_save(attribute, value)
20
20
  obj.send :"#{attribute}=", value
21
- obj.send(attribute).must_equal value
21
+ _(obj.send(attribute)).must_equal value
22
22
  obj.save!
23
- obj.reload.send(attribute).must_equal value
23
+ _(obj.reload.send(attribute)).must_equal value
24
24
  end
25
25
 
26
26
  # http://msdn.microsoft.com/en-us/library/ms187752.aspx
@@ -29,199 +29,199 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
29
29
 
30
30
  it 'int(4) PRIMARY KEY' do
31
31
  col = column('id')
32
- col.sql_type.must_equal 'int(4)'
33
- col.null.must_equal false
32
+ _(col.sql_type).must_equal 'int(4)'
33
+ _(col.null).must_equal false
34
34
  end
35
35
 
36
36
  it 'bigint(8)' do
37
37
  col = column('bigint')
38
- col.sql_type.must_equal 'bigint(8)'
39
- col.type.must_equal :integer
40
- col.null.must_equal true
41
- col.default.must_equal 42
42
- obj.bigint.must_equal 42
43
- col.default_function.must_be_nil
44
- type = connection.lookup_cast_type_from_column(col)
45
- type.must_be_instance_of Type::BigInteger
46
- type.limit.must_equal 8
38
+ _(col.sql_type).must_equal 'bigint(8)'
39
+ _(col.type).must_equal :integer
40
+ _(col.null).must_equal true
41
+ _(col.default).must_equal 42
42
+ _(obj.bigint).must_equal 42
43
+ _(col.default_function).must_be_nil
44
+ type = connection.lookup_cast_type_from_column(col)
45
+ _(type).must_be_instance_of Type::BigInteger
46
+ _(type.limit).must_equal 8
47
47
  assert_obj_set_and_save :bigint, -9_223_372_036_854_775_808
48
48
  assert_obj_set_and_save :bigint, 9_223_372_036_854_775_807
49
49
  end
50
50
 
51
51
  it 'int(4)' do
52
52
  col = column('int')
53
- col.sql_type.must_equal 'int(4)'
54
- col.type.must_equal :integer
55
- col.null.must_equal true
56
- col.default.must_equal 42
57
- obj.int.must_equal 42
58
- col.default_function.must_be_nil
59
- type = connection.lookup_cast_type_from_column(col)
60
- type.must_be_instance_of Type::Integer
61
- type.limit.must_equal 4
53
+ _(col.sql_type).must_equal 'int(4)'
54
+ _(col.type).must_equal :integer
55
+ _(col.null).must_equal true
56
+ _(col.default).must_equal 42
57
+ _(obj.int).must_equal 42
58
+ _(col.default_function).must_be_nil
59
+ type = connection.lookup_cast_type_from_column(col)
60
+ _(type).must_be_instance_of Type::Integer
61
+ _(type.limit).must_equal 4
62
62
  assert_obj_set_and_save :int, -2_147_483_648
63
63
  assert_obj_set_and_save :int, 2_147_483_647
64
64
  end
65
65
 
66
66
  it 'smallint(2)' do
67
67
  col = column('smallint')
68
- col.sql_type.must_equal 'smallint(2)'
69
- col.type.must_equal :integer
70
- col.null.must_equal true
71
- col.default.must_equal 42
72
- obj.smallint.must_equal 42
73
- col.default_function.must_be_nil
74
- type = connection.lookup_cast_type_from_column(col)
75
- type.must_be_instance_of Type::SmallInteger
76
- type.limit.must_equal 2
68
+ _(col.sql_type).must_equal 'smallint(2)'
69
+ _(col.type).must_equal :integer
70
+ _(col.null).must_equal true
71
+ _(col.default).must_equal 42
72
+ _(obj.smallint).must_equal 42
73
+ _(col.default_function).must_be_nil
74
+ type = connection.lookup_cast_type_from_column(col)
75
+ _(type).must_be_instance_of Type::SmallInteger
76
+ _(type.limit).must_equal 2
77
77
  assert_obj_set_and_save :smallint, -32_768
78
78
  assert_obj_set_and_save :smallint, 32_767
79
79
  end
80
80
 
81
81
  it 'tinyint(1)' do
82
82
  col = column('tinyint')
83
- col.sql_type.must_equal 'tinyint(1)'
84
- col.type.must_equal :integer
85
- col.null.must_equal true
86
- col.default.must_equal 42
87
- obj.tinyint.must_equal 42
88
- col.default_function.must_be_nil
89
- type = connection.lookup_cast_type_from_column(col)
90
- type.must_be_instance_of Type::TinyInteger
91
- type.limit.must_equal 1
83
+ _(col.sql_type).must_equal 'tinyint(1)'
84
+ _(col.type).must_equal :integer
85
+ _(col.null).must_equal true
86
+ _(col.default).must_equal 42
87
+ _(obj.tinyint).must_equal 42
88
+ _(col.default_function).must_be_nil
89
+ type = connection.lookup_cast_type_from_column(col)
90
+ _(type).must_be_instance_of Type::TinyInteger
91
+ _(type.limit).must_equal 1
92
92
  assert_obj_set_and_save :tinyint, 0
93
93
  assert_obj_set_and_save :tinyint, 255
94
94
  end
95
95
 
96
96
  it 'bit' do
97
97
  col = column('bit')
98
- col.sql_type.must_equal 'bit'
99
- col.type.must_equal :boolean
100
- col.null.must_equal true
101
- col.default.must_equal true
102
- obj.bit.must_equal true
103
- col.default_function.must_be_nil
104
- type = connection.lookup_cast_type_from_column(col)
105
- type.must_be_instance_of Type::Boolean
106
- type.limit.must_be_nil
98
+ _(col.sql_type).must_equal 'bit'
99
+ _(col.type).must_equal :boolean
100
+ _(col.null).must_equal true
101
+ _(col.default).must_equal true
102
+ _(obj.bit).must_equal true
103
+ _(col.default_function).must_be_nil
104
+ type = connection.lookup_cast_type_from_column(col)
105
+ _(type).must_be_instance_of Type::Boolean
106
+ _(type.limit).must_be_nil
107
107
  obj.bit = 0
108
- obj.bit.must_equal false
108
+ _(obj.bit).must_equal false
109
109
  obj.save!
110
- obj.reload.bit.must_equal false
110
+ _(obj.reload.bit).must_equal false
111
111
  obj.bit = '1'
112
- obj.bit.must_equal true
112
+ _(obj.bit).must_equal true
113
113
  obj.save!
114
- obj.reload.bit.must_equal true
114
+ _(obj.reload.bit).must_equal true
115
115
  end
116
116
 
117
117
  it 'decimal(9,2)' do
118
118
  col = column('decimal_9_2')
119
- col.sql_type.must_equal 'decimal(9,2)'
120
- col.type.must_equal :decimal
121
- col.null.must_equal true
122
- col.default.must_equal BigDecimal('12345.01')
123
- obj.decimal_9_2.must_equal BigDecimal('12345.01')
124
- col.default_function.must_be_nil
125
- type = connection.lookup_cast_type_from_column(col)
126
- type.must_be_instance_of Type::Decimal
127
- type.limit.must_be_nil
128
- type.precision.must_equal 9
129
- type.scale.must_equal 2
119
+ _(col.sql_type).must_equal 'decimal(9,2)'
120
+ _(col.type).must_equal :decimal
121
+ _(col.null).must_equal true
122
+ _(col.default).must_equal BigDecimal('12345.01')
123
+ _(obj.decimal_9_2).must_equal BigDecimal('12345.01')
124
+ _(col.default_function).must_be_nil
125
+ type = connection.lookup_cast_type_from_column(col)
126
+ _(type).must_be_instance_of Type::Decimal
127
+ _(type.limit).must_be_nil
128
+ _(type.precision).must_equal 9
129
+ _(type.scale).must_equal 2
130
130
  obj.decimal_9_2 = '1234567.8901'
131
- obj.decimal_9_2.must_equal BigDecimal('1234567.89')
131
+ _(obj.decimal_9_2).must_equal BigDecimal('1234567.89')
132
132
  obj.save!
133
- obj.reload.decimal_9_2.must_equal BigDecimal('1234567.89')
133
+ _(obj.reload.decimal_9_2).must_equal BigDecimal('1234567.89')
134
134
  end
135
135
 
136
136
  it 'decimal(16,4)' do
137
137
  col = column('decimal_16_4')
138
- col.sql_type.must_equal 'decimal(16,4)'
139
- col.default.must_equal BigDecimal('1234567.89')
140
- obj.decimal_16_4.must_equal BigDecimal('1234567.89')
141
- col.default_function.must_be_nil
138
+ _(col.sql_type).must_equal 'decimal(16,4)'
139
+ _(col.default).must_equal BigDecimal('1234567.89')
140
+ _(obj.decimal_16_4).must_equal BigDecimal('1234567.89')
141
+ _(col.default_function).must_be_nil
142
142
  type = connection.lookup_cast_type_from_column(col)
143
- type.precision.must_equal 16
144
- type.scale.must_equal 4
143
+ _(type.precision).must_equal 16
144
+ _(type.scale).must_equal 4
145
145
  obj.decimal_16_4 = '1234567.8901001'
146
- obj.decimal_16_4.must_equal BigDecimal('1234567.8901')
146
+ _(obj.decimal_16_4).must_equal BigDecimal('1234567.8901')
147
147
  obj.save!
148
- obj.reload.decimal_16_4.must_equal BigDecimal('1234567.8901')
148
+ _(obj.reload.decimal_16_4).must_equal BigDecimal('1234567.8901')
149
149
  end
150
150
 
151
151
  it 'numeric(18,0)' do
152
152
  col = column('numeric_18_0')
153
- col.sql_type.must_equal 'numeric(18,0)'
154
- col.type.must_equal :decimal
155
- col.null.must_equal true
156
- col.default.must_equal BigDecimal('191')
157
- obj.numeric_18_0.must_equal BigDecimal('191')
158
- col.default_function.must_be_nil
159
- type = connection.lookup_cast_type_from_column(col)
160
- type.must_be_instance_of Type::Decimal
161
- type.limit.must_be_nil
162
- type.precision.must_equal 18
163
- type.scale.must_equal 0
153
+ _(col.sql_type).must_equal 'numeric(18,0)'
154
+ _(col.type).must_equal :decimal
155
+ _(col.null).must_equal true
156
+ _(col.default).must_equal BigDecimal('191')
157
+ _(obj.numeric_18_0).must_equal BigDecimal('191')
158
+ _(col.default_function).must_be_nil
159
+ type = connection.lookup_cast_type_from_column(col)
160
+ _(type).must_be_instance_of Type::Decimal
161
+ _(type.limit).must_be_nil
162
+ _(type.precision).must_equal 18
163
+ _(type.scale).must_equal 0
164
164
  obj.numeric_18_0 = '192.1'
165
- obj.numeric_18_0.must_equal BigDecimal('192')
165
+ _(obj.numeric_18_0).must_equal BigDecimal('192')
166
166
  obj.save!
167
- obj.reload.numeric_18_0.must_equal BigDecimal('192')
167
+ _(obj.reload.numeric_18_0).must_equal BigDecimal('192')
168
168
  end
169
169
 
170
170
  it 'numeric(36,2)' do
171
171
  col = column('numeric_36_2')
172
- col.sql_type.must_equal 'numeric(36,2)'
173
- col.type.must_equal :decimal
174
- col.null.must_equal true
175
- col.default.must_equal BigDecimal('12345678901234567890.01')
176
- obj.numeric_36_2.must_equal BigDecimal('12345678901234567890.01')
177
- col.default_function.must_be_nil
178
- type = connection.lookup_cast_type_from_column(col)
179
- type.must_be_instance_of Type::Decimal
180
- type.limit.must_be_nil
181
- type.precision.must_equal 36
182
- type.scale.must_equal 2
172
+ _(col.sql_type).must_equal 'numeric(36,2)'
173
+ _(col.type).must_equal :decimal
174
+ _(col.null).must_equal true
175
+ _(col.default).must_equal BigDecimal('12345678901234567890.01')
176
+ _(obj.numeric_36_2).must_equal BigDecimal('12345678901234567890.01')
177
+ _(col.default_function).must_be_nil
178
+ type = connection.lookup_cast_type_from_column(col)
179
+ _(type).must_be_instance_of Type::Decimal
180
+ _(type.limit).must_be_nil
181
+ _(type.precision).must_equal 36
182
+ _(type.scale).must_equal 2
183
183
  obj.numeric_36_2 = '192.123'
184
- obj.numeric_36_2.must_equal BigDecimal('192.12')
184
+ _(obj.numeric_36_2).must_equal BigDecimal('192.12')
185
185
  obj.save!
186
- obj.reload.numeric_36_2.must_equal BigDecimal('192.12')
186
+ _(obj.reload.numeric_36_2).must_equal BigDecimal('192.12')
187
187
  end
188
188
 
189
189
  it 'money' do
190
190
  col = column('money')
191
- col.sql_type.must_equal 'money'
192
- col.type.must_equal :money
193
- col.null.must_equal true
194
- col.default.must_equal BigDecimal('4.20')
195
- obj.money.must_equal BigDecimal('4.20')
196
- col.default_function.must_be_nil
197
- type = connection.lookup_cast_type_from_column(col)
198
- type.must_be_instance_of Type::Money
199
- type.limit.must_be_nil
200
- type.precision.must_equal 19
201
- type.scale.must_equal 4
191
+ _(col.sql_type).must_equal 'money'
192
+ _(col.type).must_equal :money
193
+ _(col.null).must_equal true
194
+ _(col.default).must_equal BigDecimal('4.20')
195
+ _(obj.money).must_equal BigDecimal('4.20')
196
+ _(col.default_function).must_be_nil
197
+ type = connection.lookup_cast_type_from_column(col)
198
+ _(type).must_be_instance_of Type::Money
199
+ _(type.limit).must_be_nil
200
+ _(type.precision).must_equal 19
201
+ _(type.scale).must_equal 4
202
202
  obj.money = '922337203685477.58061'
203
- obj.money.must_equal BigDecimal('922337203685477.5806')
203
+ _(obj.money).must_equal BigDecimal('922337203685477.5806')
204
204
  obj.save!
205
- obj.reload.money.must_equal BigDecimal('922337203685477.5806')
205
+ _(obj.reload.money).must_equal BigDecimal('922337203685477.5806')
206
206
  end
207
207
 
208
208
  it 'smallmoney' do
209
209
  col = column('smallmoney')
210
- col.sql_type.must_equal 'smallmoney'
211
- col.type.must_equal :smallmoney
212
- col.null.must_equal true
213
- col.default.must_equal BigDecimal('4.20')
214
- obj.smallmoney.must_equal BigDecimal('4.20')
215
- col.default_function.must_be_nil
216
- type = connection.lookup_cast_type_from_column(col)
217
- type.must_be_instance_of Type::SmallMoney
218
- type.limit.must_be_nil
219
- type.precision.must_equal 10
220
- type.scale.must_equal 4
210
+ _(col.sql_type).must_equal 'smallmoney'
211
+ _(col.type).must_equal :smallmoney
212
+ _(col.null).must_equal true
213
+ _(col.default).must_equal BigDecimal('4.20')
214
+ _(obj.smallmoney).must_equal BigDecimal('4.20')
215
+ _(col.default_function).must_be_nil
216
+ type = connection.lookup_cast_type_from_column(col)
217
+ _(type).must_be_instance_of Type::SmallMoney
218
+ _(type.limit).must_be_nil
219
+ _(type.precision).must_equal 10
220
+ _(type.scale).must_equal 4
221
221
  obj.smallmoney = '214748.36461'
222
- obj.smallmoney.must_equal BigDecimal('214748.3646')
222
+ _(obj.smallmoney).must_equal BigDecimal('214748.3646')
223
223
  obj.save!
224
- obj.reload.smallmoney.must_equal BigDecimal('214748.3646')
224
+ _(obj.reload.smallmoney).must_equal BigDecimal('214748.3646')
225
225
  end
226
226
 
227
227
  # Approximate Numerics
@@ -230,386 +230,418 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
230
230
 
231
231
  it 'float' do
232
232
  col = column('float')
233
- col.sql_type.must_equal 'float'
234
- col.type.must_equal :float
235
- col.null.must_equal true
236
- col.default.must_equal 123.00000001
237
- obj.float.must_equal 123.00000001
238
- col.default_function.must_be_nil
239
- type = connection.lookup_cast_type_from_column(col)
240
- type.must_be_instance_of Type::Float
241
- type.limit.must_be_nil
242
- type.precision.must_be_nil
243
- type.scale.must_be_nil
233
+ _(col.sql_type).must_equal 'float'
234
+ _(col.type).must_equal :float
235
+ _(col.null).must_equal true
236
+ _(col.default).must_equal 123.00000001
237
+ _(obj.float).must_equal 123.00000001
238
+ _(col.default_function).must_be_nil
239
+ type = connection.lookup_cast_type_from_column(col)
240
+ _(type).must_be_instance_of Type::Float
241
+ _(type.limit).must_be_nil
242
+ _(type.precision).must_be_nil
243
+ _(type.scale).must_be_nil
244
244
  obj.float = '214748.36461'
245
- obj.float.must_equal 214748.36461
245
+ _(obj.float).must_equal 214748.36461
246
246
  obj.save!
247
- obj.reload.float.must_equal 214748.36461
247
+ _(obj.reload.float).must_equal 214748.36461
248
248
  end
249
249
 
250
250
  it 'real' do
251
251
  col = column('real')
252
- col.sql_type.must_equal 'real'
253
- col.type.must_equal :real
254
- col.null.must_equal true
255
- col.default.must_be_close_to 123.45, 0.01
256
- obj.real.must_be_close_to 123.45, 0.01
257
- col.default_function.must_be_nil
258
- type = connection.lookup_cast_type_from_column(col)
259
- type.must_be_instance_of Type::Real
260
- type.limit.must_be_nil
261
- type.precision.must_be_nil
262
- type.scale.must_be_nil
252
+ _(col.sql_type).must_equal 'real'
253
+ _(col.type).must_equal :real
254
+ _(col.null).must_equal true
255
+ _(col.default).must_be_close_to 123.45, 0.01
256
+ _(obj.real).must_be_close_to 123.45, 0.01
257
+ _(col.default_function).must_be_nil
258
+ type = connection.lookup_cast_type_from_column(col)
259
+ _(type).must_be_instance_of Type::Real
260
+ _(type.limit).must_be_nil
261
+ _(type.precision).must_be_nil
262
+ _(type.scale).must_be_nil
263
263
  obj.real = '214748.36461'
264
- obj.real.must_be_close_to 214748.36461, 0.01
264
+ _(obj.real).must_be_close_to 214748.36461, 0.01
265
265
  obj.save!
266
- obj.reload.real.must_be_close_to 214748.36461, 0.01
266
+ _(obj.reload.real).must_be_close_to 214748.36461, 0.01
267
267
  end
268
268
 
269
269
  # Date and Time
270
270
 
271
271
  it 'date' do
272
272
  col = column('date')
273
- col.sql_type.must_equal 'date'
274
- col.type.must_equal :date
275
- col.null.must_equal true
276
- col.default.must_equal connection_dblib_73? ? Date.civil(0001, 1, 1) : '0001-01-01'
277
- obj.date.must_equal Date.civil(0001, 1, 1)
278
- col.default_function.must_be_nil
279
- type = connection.lookup_cast_type_from_column(col)
280
- type.must_be_instance_of Type::Date
281
- type.limit.must_be_nil
282
- type.precision.must_be_nil
283
- type.scale.must_be_nil
273
+ _(col.sql_type).must_equal 'date'
274
+ _(col.type).must_equal :date
275
+ _(col.null).must_equal true
276
+ _(col.default).must_equal connection_dblib_73? ? Date.civil(0001, 1, 1) : '0001-01-01'
277
+ _(obj.date).must_equal Date.civil(0001, 1, 1)
278
+ _(col.default_function).must_be_nil
279
+ type = connection.lookup_cast_type_from_column(col)
280
+ _(type).must_be_instance_of Type::Date
281
+ _(type.limit).must_be_nil
282
+ _(type.precision).must_be_nil
283
+ _(type.scale).must_be_nil
284
284
  # Can cast strings. SQL Server format.
285
285
  obj.date = '04-01-0001'
286
- obj.date.must_equal Date.civil(0001, 4, 1)
286
+ _(obj.date).must_equal Date.civil(0001, 4, 1)
287
287
  obj.save!
288
- obj.date.must_equal Date.civil(0001, 4, 1)
288
+ _(obj.date).must_equal Date.civil(0001, 4, 1)
289
289
  obj.reload
290
- obj.date.must_equal Date.civil(0001, 4, 1)
290
+ _(obj.date).must_equal Date.civil(0001, 4, 1)
291
291
  # Can cast strings. ISO format.
292
292
  obj.date = '0001-04-01'
293
- obj.date.must_equal Date.civil(0001, 4, 1)
293
+ _(obj.date).must_equal Date.civil(0001, 4, 1)
294
294
  obj.save!
295
- obj.date.must_equal Date.civil(0001, 4, 1)
295
+ _(obj.date).must_equal Date.civil(0001, 4, 1)
296
296
  obj.reload
297
- obj.date.must_equal Date.civil(0001, 4, 1)
297
+ _(obj.date).must_equal Date.civil(0001, 4, 1)
298
298
  # Can keep and return assigned date.
299
299
  assert_obj_set_and_save :date, Date.civil(1972, 04, 14)
300
300
  # Can accept and cast time objects.
301
301
  obj.date = Time.utc(2010, 4, 14, 12, 34, 56, 3000)
302
- obj.date.must_equal Date.civil(2010, 4, 14)
302
+ _(obj.date).must_equal Date.civil(2010, 4, 14)
303
303
  obj.save!
304
- obj.reload.date.must_equal Date.civil(2010, 4, 14)
304
+ _(obj.reload.date).must_equal Date.civil(2010, 4, 14)
305
305
  end
306
306
 
307
307
  it 'datetime' do
308
308
  col = column('datetime')
309
- col.sql_type.must_equal 'datetime'
310
- col.type.must_equal :datetime
311
- col.null.must_equal true
309
+ _(col.sql_type).must_equal 'datetime'
310
+ _(col.type).must_equal :datetime
311
+ _(col.null).must_equal true
312
312
  time = Time.utc 1753, 01, 01, 00, 00, 00, 123000
313
- col.default.must_equal time, "Microseconds were <#{col.default.usec}> vs <123000>"
314
- obj.datetime.must_equal time, "Microseconds were <#{obj.datetime.usec}> vs <123000>"
315
- col.default_function.must_be_nil
313
+ _(col.default).must_equal time, "Microseconds were <#{col.default.usec}> vs <123000>"
314
+ _(obj.datetime).must_equal time, "Microseconds were <#{obj.datetime.usec}> vs <123000>"
315
+ _(col.default_function).must_be_nil
316
316
  type = connection.lookup_cast_type_from_column(col)
317
- type.must_be_instance_of Type::DateTime
318
- type.limit.must_be_nil
319
- type.precision.must_be_nil
320
- type.scale.must_be_nil
317
+ _(type).must_be_instance_of Type::DateTime
318
+ _(type.limit).must_be_nil
319
+ _(type.precision).must_be_nil
320
+ _(type.scale).must_be_nil
321
321
  obj.save!
322
- obj.must_equal obj.class.where(datetime: time).first
322
+ _(obj).must_equal obj.class.where(datetime: time).first
323
323
  # Can save to proper accuracy and return again.
324
324
  time = Time.utc 2010, 04, 01, 12, 34, 56, 3000
325
325
  obj.datetime = time
326
- obj.datetime.must_equal time, "Microseconds were <#{obj.datetime.usec}> vs <3000>"
326
+ _(obj.datetime).must_equal time, "Microseconds were <#{obj.datetime.usec}> vs <3000>"
327
327
  obj.save!
328
- obj.datetime.must_equal time, "Microseconds were <#{obj.datetime.usec}> vs <3000>"
328
+ _(obj.datetime).must_equal time, "Microseconds were <#{obj.datetime.usec}> vs <3000>"
329
329
  obj.reload
330
- obj.datetime.must_equal time, "Microseconds were <#{obj.datetime.usec}> vs <3000>"
331
- obj.must_equal obj.class.where(datetime: time).first
330
+ _(obj.datetime).must_equal time, "Microseconds were <#{obj.datetime.usec}> vs <3000>"
331
+ _(obj).must_equal obj.class.where(datetime: time).first
332
332
  # Will cast to true DB value on attribute write, save and return again.
333
333
  time = Time.utc 2010, 04, 01, 12, 34, 56, 234567
334
334
  time2 = Time.utc 2010, 04, 01, 12, 34, 56, 233000
335
335
  obj.datetime = time
336
- obj.datetime.must_equal time2, "Microseconds were <#{obj.datetime.usec}> vs <233000>"
336
+ _(obj.datetime).must_equal time2, "Microseconds were <#{obj.datetime.usec}> vs <233000>"
337
337
  obj.save!
338
- obj.datetime.must_equal time2, "Microseconds were <#{obj.datetime.usec}> vs <233000>"
338
+ _(obj.datetime).must_equal time2, "Microseconds were <#{obj.datetime.usec}> vs <233000>"
339
339
  obj.reload
340
- obj.datetime.must_equal time2, "Microseconds were <#{obj.datetime.usec}> vs <233000>"
341
- obj.must_equal obj.class.where(datetime: time).first
342
- obj.must_equal obj.class.where(datetime: time2).first
340
+ _(obj.datetime).must_equal time2, "Microseconds were <#{obj.datetime.usec}> vs <233000>"
341
+ _(obj).must_equal obj.class.where(datetime: time).first
342
+ _(obj).must_equal obj.class.where(datetime: time2).first
343
343
  # Set and find nil.
344
344
  obj.datetime = nil
345
- obj.datetime.must_be_nil
345
+ _(obj.datetime).must_be_nil
346
346
  obj.save!
347
- obj.datetime.must_be_nil
348
- obj.must_equal obj.class.where(datetime: nil).first
347
+ _(obj.datetime).must_be_nil
348
+ _(obj).must_equal obj.class.where(datetime: nil).first
349
349
  end
350
350
 
351
351
  it 'datetime2' do
352
- skip 'datetime2 not supported in this protocal version' unless connection_dblib_73?
352
+ skip 'datetime2 not supported in this protocol version' unless connection_dblib_73?
353
353
  col = column('datetime2_7')
354
- col.sql_type.must_equal 'datetime2(7)'
355
- col.type.must_equal :datetime
356
- col.null.must_equal true
354
+ _(col.sql_type).must_equal 'datetime2(7)'
355
+ _(col.type).must_equal :datetime
356
+ _(col.null).must_equal true
357
357
  time = Time.utc 9999, 12, 31, 23, 59, 59, Rational(999999900, 1000)
358
- col.default.must_equal time, "Nanoseconds were <#{col.default.nsec}> vs <999999900>"
359
- obj.datetime2_7.must_equal time, "Nanoseconds were <#{obj.datetime2_7.nsec}> vs <999999900>"
360
- col.default_function.must_be_nil
358
+ _(col.default).must_equal time, "Nanoseconds were <#{col.default.nsec}> vs <999999900>"
359
+ _(obj.datetime2_7).must_equal time, "Nanoseconds were <#{obj.datetime2_7.nsec}> vs <999999900>"
360
+ _(col.default_function).must_be_nil
361
361
  type = connection.lookup_cast_type_from_column(col)
362
- type.must_be_instance_of Type::DateTime2
363
- type.limit.must_be_nil
364
- type.precision.must_equal 7
365
- type.scale.must_be_nil
362
+ _(type).must_be_instance_of Type::DateTime2
363
+ _(type.limit).must_be_nil
364
+ _(type.precision).must_equal 7
365
+ _(type.scale).must_be_nil
366
366
  obj.save!
367
- obj.must_equal obj.class.where(datetime2_7: time).first
367
+ _(obj).must_equal obj.class.where(datetime2_7: time).first
368
368
  # Can save 100 nanosecond precisoins and return again.
369
369
  time = Time.utc 9999, 12, 31, 23, 59, 59, Rational(123456755, 1000)
370
370
  time2 = Time.utc 9999, 12, 31, 23, 59, 59, Rational(123456800, 1000)
371
371
  obj.datetime2_7 = time
372
- obj.datetime2_7.must_equal time2, "Nanoseconds were <#{obj.datetime2_7.nsec}> vs <123456800>"
372
+ _(obj.datetime2_7).must_equal time2, "Nanoseconds were <#{obj.datetime2_7.nsec}> vs <123456800>"
373
373
  obj.save!
374
- obj.datetime2_7.must_equal time2, "Nanoseconds were <#{obj.datetime2_7.nsec}> vs <123456800>"
374
+ _(obj.datetime2_7).must_equal time2, "Nanoseconds were <#{obj.datetime2_7.nsec}> vs <123456800>"
375
375
  obj.reload
376
- obj.datetime2_7.must_equal time2, "Nanoseconds were <#{obj.datetime2_7.nsec}> vs <123456800>"
377
- obj.must_equal obj.class.where(datetime2_7: time).first
378
- obj.must_equal obj.class.where(datetime2_7: time2).first
376
+ _(obj.datetime2_7).must_equal time2, "Nanoseconds were <#{obj.datetime2_7.nsec}> vs <123456800>"
377
+ _(obj).must_equal obj.class.where(datetime2_7: time).first
378
+ _(obj).must_equal obj.class.where(datetime2_7: time2).first
379
379
  # Can save small fraction nanosecond precisoins and return again.
380
380
  time = Time.utc 2008, 6, 21, 13, 30, 0, Rational(15020, 1000)
381
381
  time2 = Time.utc 2008, 6, 21, 13, 30, 0, Rational(15000, 1000)
382
382
  obj.datetime2_7 = time
383
- obj.datetime2_7.must_equal time2, "Nanoseconds were <#{obj.datetime2_7.nsec}> vs <15000>"
383
+ _(obj.datetime2_7).must_equal time2, "Nanoseconds were <#{obj.datetime2_7.nsec}> vs <15000>"
384
384
  obj.save!
385
- obj.reload.datetime2_7.must_equal time2, "Nanoseconds were <#{obj.datetime2_7.nsec}> vs <15000>"
386
- obj.must_equal obj.class.where(datetime2_7: time).first
387
- obj.must_equal obj.class.where(datetime2_7: time2).first
385
+ _(obj.reload.datetime2_7).must_equal time2, "Nanoseconds were <#{obj.datetime2_7.nsec}> vs <15000>"
386
+ _(obj).must_equal obj.class.where(datetime2_7: time).first
387
+ _(obj).must_equal obj.class.where(datetime2_7: time2).first
388
388
  # datetime2_3
389
389
  time = Time.utc 9999, 12, 31, 23, 59, 59, Rational(123456789, 1000)
390
390
  col = column('datetime2_3')
391
- connection.lookup_cast_type_from_column(col).precision.must_equal 3
391
+ _(connection.lookup_cast_type_from_column(col).precision).must_equal 3
392
392
  obj.datetime2_3 = time
393
- obj.datetime2_3.must_equal time.change(nsec: 123000000), "Nanoseconds were <#{obj.datetime2_3.nsec}> vs <123000000>"
393
+ _(obj.datetime2_3).must_equal time.change(nsec: 123000000), "Nanoseconds were <#{obj.datetime2_3.nsec}> vs <123000000>"
394
394
  obj.save! ; obj.reload
395
- obj.datetime2_3.must_equal time.change(nsec: 123000000), "Nanoseconds were <#{obj.datetime2_3.nsec}> vs <123000000>"
396
- obj.must_equal obj.class.where(datetime2_3: time).first
395
+ _(obj.datetime2_3).must_equal time.change(nsec: 123000000), "Nanoseconds were <#{obj.datetime2_3.nsec}> vs <123000000>"
396
+ _(obj).must_equal obj.class.where(datetime2_3: time).first
397
397
  # datetime2_1
398
398
  col = column('datetime2_1')
399
- connection.lookup_cast_type_from_column(col).precision.must_equal 1
399
+ _(connection.lookup_cast_type_from_column(col).precision).must_equal 1
400
400
  obj.datetime2_1 = time
401
- obj.datetime2_1.must_equal time.change(nsec: 100000000), "Nanoseconds were <#{obj.datetime2_1.nsec}> vs <100000000>"
401
+ _(obj.datetime2_1).must_equal time.change(nsec: 100000000), "Nanoseconds were <#{obj.datetime2_1.nsec}> vs <100000000>"
402
402
  obj.save! ; obj.reload
403
- obj.datetime2_1.must_equal time.change(nsec: 100000000), "Nanoseconds were <#{obj.datetime2_1.nsec}> vs <100000000>"
404
- obj.must_equal obj.class.where(datetime2_1: time).first
403
+ _(obj.datetime2_1).must_equal time.change(nsec: 100000000), "Nanoseconds were <#{obj.datetime2_1.nsec}> vs <100000000>"
404
+ _(obj).must_equal obj.class.where(datetime2_1: time).first
405
405
  # datetime2_0
406
406
  col = column('datetime2_0')
407
- connection.lookup_cast_type_from_column(col).precision.must_equal 0
407
+ _(connection.lookup_cast_type_from_column(col).precision).must_equal 0
408
408
  time = Time.utc 2016, 4, 19, 16, 45, 40, 771036
409
409
  obj.datetime2_0 = time
410
- obj.datetime2_0.must_equal time.change(nsec: 0), "Nanoseconds were <#{obj.datetime2_0.nsec}> vs <0>"
410
+ _(obj.datetime2_0).must_equal time.change(nsec: 0), "Nanoseconds were <#{obj.datetime2_0.nsec}> vs <0>"
411
411
  obj.save! ; obj.reload
412
- obj.datetime2_0.must_equal time.change(nsec: 0), "Nanoseconds were <#{obj.datetime2_0.nsec}> vs <0>"
413
- obj.must_equal obj.class.where(datetime2_0: time).first
412
+ _(obj.datetime2_0).must_equal time.change(nsec: 0), "Nanoseconds were <#{obj.datetime2_0.nsec}> vs <0>"
413
+ _(obj).must_equal obj.class.where(datetime2_0: time).first
414
414
  end
415
415
 
416
416
  it 'datetimeoffset' do
417
- skip 'datetimeoffset not supported in this protocal version' unless connection_dblib_73?
417
+ skip 'datetimeoffset not supported in this protocol version' unless connection_dblib_73?
418
418
  col = column('datetimeoffset_7')
419
- col.sql_type.must_equal 'datetimeoffset(7)'
420
- col.type.must_equal :datetimeoffset
421
- col.null.must_equal true
422
- col.default.must_equal Time.new(1984, 01, 24, 04, 20, 00, -28800).change(nsec: 123456700), "Nanoseconds <#{col.default.nsec}> vs <123456700>"
423
- obj.datetimeoffset_7.must_equal Time.new(1984, 01, 24, 04, 20, 00, -28800).change(nsec: 123456700), "Nanoseconds were <#{obj.datetimeoffset_7.nsec}> vs <999999900>"
424
- col.default_function.must_be_nil
425
- type = connection.lookup_cast_type_from_column(col)
426
- type.must_be_instance_of Type::DateTimeOffset
427
- type.limit.must_be_nil
428
- type.precision.must_equal 7
429
- type.scale.must_be_nil
419
+ _(col.sql_type).must_equal 'datetimeoffset(7)'
420
+ _(col.type).must_equal :datetimeoffset
421
+ _(col.null).must_equal true
422
+ _(col.default).must_equal Time.new(1984, 01, 24, 04, 20, 00, -28800).change(nsec: 123456700), "Nanoseconds <#{col.default.nsec}> vs <123456700>"
423
+ _(obj.datetimeoffset_7).must_equal Time.new(1984, 01, 24, 04, 20, 00, -28800).change(nsec: 123456700), "Nanoseconds were <#{obj.datetimeoffset_7.nsec}> vs <999999900>"
424
+ _(col.default_function).must_be_nil
425
+ type = connection.lookup_cast_type_from_column(col)
426
+ _(type).must_be_instance_of Type::DateTimeOffset
427
+ _(type.limit).must_be_nil
428
+ _(type.precision).must_equal 7
429
+ _(type.scale).must_be_nil
430
430
  # Can save 100 nanosecond precisoins and return again.
431
431
  obj.datetimeoffset_7 = Time.new(2010, 04, 01, 12, 34, 56, +18000).change(nsec: 123456755)
432
- obj.datetimeoffset_7.must_equal Time.new(2010, 04, 01, 12, 34, 56, +18000).change(nsec: 123456800), "Nanoseconds were <#{obj.datetimeoffset_7.nsec}> vs <123456800>"
432
+ _(obj.datetimeoffset_7).must_equal Time.new(2010, 04, 01, 12, 34, 56, +18000).change(nsec: 123456800), "Nanoseconds were <#{obj.datetimeoffset_7.nsec}> vs <123456800>"
433
433
  obj.save!
434
- obj.datetimeoffset_7.must_equal Time.new(2010, 04, 01, 12, 34, 56, +18000).change(nsec: 123456800), "Nanoseconds were <#{obj.datetimeoffset_7.nsec}> vs <123456800>"
434
+ _(obj.datetimeoffset_7).must_equal Time.new(2010, 04, 01, 12, 34, 56, +18000).change(nsec: 123456800), "Nanoseconds were <#{obj.datetimeoffset_7.nsec}> vs <123456800>"
435
435
  obj.reload
436
- obj.datetimeoffset_7.must_equal Time.new(2010, 04, 01, 12, 34, 56, +18000).change(nsec: 123456800), "Nanoseconds were <#{obj.datetimeoffset_7.nsec}> vs <123456800>"
436
+ _(obj.datetimeoffset_7).must_equal Time.new(2010, 04, 01, 12, 34, 56, +18000).change(nsec: 123456800), "Nanoseconds were <#{obj.datetimeoffset_7.nsec}> vs <123456800>"
437
437
  # Maintains the timezone
438
438
  time = ActiveSupport::TimeZone['America/Los_Angeles'].local 2010, 12, 31, 23, 59, 59, Rational(123456800, 1000)
439
439
  obj.datetimeoffset_7 = time
440
- obj.datetimeoffset_7.must_equal time
440
+ _(obj.datetimeoffset_7).must_equal time
441
441
  obj.save!
442
- obj.datetimeoffset_7.must_equal time
443
- obj.reload.datetimeoffset_7.must_equal time
442
+ _(obj.datetimeoffset_7).must_equal time
443
+ _(obj.reload.datetimeoffset_7).must_equal time
444
444
  # With other precisions.
445
445
  time = ActiveSupport::TimeZone['America/Los_Angeles'].local 2010, 12, 31, 23, 59, 59, Rational(123456755, 1000)
446
446
  col = column('datetimeoffset_3')
447
- connection.lookup_cast_type_from_column(col).precision.must_equal 3
447
+ _(connection.lookup_cast_type_from_column(col).precision).must_equal 3
448
448
  obj.datetimeoffset_3 = time
449
- obj.datetimeoffset_3.must_equal time.change(nsec: 123000000), "Nanoseconds were <#{obj.datetimeoffset_3.nsec}> vs <123000000>"
449
+ _(obj.datetimeoffset_3).must_equal time.change(nsec: 123000000), "Nanoseconds were <#{obj.datetimeoffset_3.nsec}> vs <123000000>"
450
450
  obj.save!
451
- obj.datetimeoffset_3.must_equal time.change(nsec: 123000000), "Nanoseconds were <#{obj.datetimeoffset_3.nsec}> vs <123000000>"
451
+ _(obj.datetimeoffset_3).must_equal time.change(nsec: 123000000), "Nanoseconds were <#{obj.datetimeoffset_3.nsec}> vs <123000000>"
452
452
  col = column('datetime2_1')
453
- connection.lookup_cast_type_from_column(col).precision.must_equal 1
453
+ _(connection.lookup_cast_type_from_column(col).precision).must_equal 1
454
454
  obj.datetime2_1 = time
455
- obj.datetime2_1.must_equal time.change(nsec: 100000000), "Nanoseconds were <#{obj.datetime2_1.nsec}> vs <100000000>"
455
+ _(obj.datetime2_1).must_equal time.change(nsec: 100000000), "Nanoseconds were <#{obj.datetime2_1.nsec}> vs <100000000>"
456
456
  obj.save!
457
- obj.datetime2_1.must_equal time.change(nsec: 100000000), "Nanoseconds were <#{obj.datetime2_1.nsec}> vs <100000000>"
457
+ _(obj.datetime2_1).must_equal time.change(nsec: 100000000), "Nanoseconds were <#{obj.datetime2_1.nsec}> vs <100000000>"
458
458
  end
459
459
 
460
460
  it 'smalldatetime' do
461
461
  col = column('smalldatetime')
462
- col.sql_type.must_equal 'smalldatetime'
463
- col.type.must_equal :smalldatetime
464
- col.null.must_equal true
465
- col.default.must_equal Time.utc(1901, 01, 01, 15, 45, 00, 000)
466
- obj.smalldatetime.must_equal Time.utc(1901, 01, 01, 15, 45, 00, 000)
467
- col.default_function.must_be_nil
468
- type = connection.lookup_cast_type_from_column(col)
469
- type.must_be_instance_of Type::SmallDateTime
470
- type.limit.must_be_nil
471
- type.precision.must_be_nil
472
- type.scale.must_be_nil
462
+ _(col.sql_type).must_equal 'smalldatetime'
463
+ _(col.type).must_equal :smalldatetime
464
+ _(col.null).must_equal true
465
+ _(col.default).must_equal Time.utc(1901, 01, 01, 15, 45, 00, 000)
466
+ _(obj.smalldatetime).must_equal Time.utc(1901, 01, 01, 15, 45, 00, 000)
467
+ _(col.default_function).must_be_nil
468
+ type = connection.lookup_cast_type_from_column(col)
469
+ _(type).must_be_instance_of Type::SmallDateTime
470
+ _(type.limit).must_be_nil
471
+ _(type.precision).must_be_nil
472
+ _(type.scale).must_be_nil
473
473
  # Will remove fractional seconds and return again.
474
474
  obj.smalldatetime = Time.utc(2078, 06, 05, 4, 20, 00, 3000)
475
- obj.smalldatetime.must_equal Time.utc(2078, 06, 05, 4, 20, 00, 0), "Microseconds were <#{obj.smalldatetime.usec}> vs <0>"
475
+ _(obj.smalldatetime).must_equal Time.utc(2078, 06, 05, 4, 20, 00, 0), "Microseconds were <#{obj.smalldatetime.usec}> vs <0>"
476
476
  obj.save!
477
- obj.smalldatetime.must_equal Time.utc(2078, 06, 05, 4, 20, 00, 0), "Microseconds were <#{obj.reload.smalldatetime.usec}> vs <0>"
477
+ _(obj.smalldatetime).must_equal Time.utc(2078, 06, 05, 4, 20, 00, 0), "Microseconds were <#{obj.reload.smalldatetime.usec}> vs <0>"
478
478
  obj.reload
479
- obj.smalldatetime.must_equal Time.utc(2078, 06, 05, 4, 20, 00, 0), "Microseconds were <#{obj.reload.smalldatetime.usec}> vs <0>"
479
+ _(obj.smalldatetime).must_equal Time.utc(2078, 06, 05, 4, 20, 00, 0), "Microseconds were <#{obj.reload.smalldatetime.usec}> vs <0>"
480
480
  end
481
481
 
482
482
  it 'time(7)' do
483
- skip 'time() not supported in this protocal version' unless connection_dblib_73?
483
+ skip 'time() not supported in this protocol version' unless connection_dblib_73?
484
484
  col = column('time_7')
485
- col.sql_type.must_equal 'time(7)'
486
- col.type.must_equal :time
487
- col.null.must_equal true
488
- col.default.must_equal Time.utc(1900, 01, 01, 04, 20, 00, Rational(288321500, 1000)), "Nanoseconds were <#{col.default.nsec}> vs <288321500>"
489
- col.default_function.must_be_nil
490
- type = connection.lookup_cast_type_from_column(col)
491
- type.must_be_instance_of Type::Time
492
- type.limit.must_be_nil
493
- type.precision.must_equal 7
494
- type.scale.must_be_nil
485
+ _(col.sql_type).must_equal 'time(7)'
486
+ _(col.type).must_equal :time
487
+ _(col.null).must_equal true
488
+ _(col.default).must_equal Time.utc(1900, 01, 01, 04, 20, 00, Rational(288321500, 1000)), "Nanoseconds were <#{col.default.nsec}> vs <288321500>"
489
+ _(col.default_function).must_be_nil
490
+ type = connection.lookup_cast_type_from_column(col)
491
+ _(type).must_be_instance_of Type::Time
492
+ _(type.limit).must_be_nil
493
+ _(type.precision).must_equal 7
494
+ _(type.scale).must_be_nil
495
495
  # Time's #usec precision (low micro)
496
496
  obj.time_7 = Time.utc(2000, 01, 01, 15, 45, 00, 300)
497
- obj.time_7.must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Microseconds were <#{obj.time_7.usec}> vs <0>"
498
- obj.time_7.must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Nanoseconds were <#{obj.time_7.nsec}> vs <300>"
497
+ _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Microseconds were <#{obj.time_7.usec}> vs <0>"
498
+ _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Nanoseconds were <#{obj.time_7.nsec}> vs <300>"
499
499
  obj.save! ; obj.reload
500
- obj.time_7.must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Microseconds were <#{obj.time_7.usec}> vs <0>"
501
- obj.time_7.must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Nanoseconds were <#{obj.time_7.nsec}> vs <300>"
500
+ _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Microseconds were <#{obj.time_7.usec}> vs <0>"
501
+ _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Nanoseconds were <#{obj.time_7.nsec}> vs <300>"
502
502
  # Time's #usec precision (high micro)
503
503
  obj.time_7 = Time.utc(2000, 01, 01, 15, 45, 00, 234567)
504
- obj.time_7.must_equal Time.utc(2000, 01, 01, 15, 45, 00, 234567), "Microseconds were <#{obj.time_7.usec}> vs <234567>"
504
+ _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 234567), "Microseconds were <#{obj.time_7.usec}> vs <234567>"
505
505
  obj.save! ; obj.reload
506
- obj.time_7.must_equal Time.utc(2000, 01, 01, 15, 45, 00, 234567), "Microseconds were <#{obj.time_7.usec}> vs <234567>"
506
+ _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 234567), "Microseconds were <#{obj.time_7.usec}> vs <234567>"
507
507
  # Time's #usec precision (high nano rounded)
508
508
  obj.time_7 = Time.utc(2000, 01, 01, 15, 45, 00, Rational(288321545, 1000))
509
- obj.time_7.must_equal Time.utc(2000, 01, 01, 15, 45, 00, Rational(288321500, 1000)), "Nanoseconds were <#{obj.time_7.nsec}> vs <288321500>"
509
+ _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, Rational(288321500, 1000)), "Nanoseconds were <#{obj.time_7.nsec}> vs <288321500>"
510
510
  obj.save! ; obj.reload
511
- obj.time_7.must_equal Time.utc(2000, 01, 01, 15, 45, 00, Rational(288321500, 1000)), "Nanoseconds were <#{obj.time_7.nsec}> vs <288321500>"
511
+ _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, Rational(288321500, 1000)), "Nanoseconds were <#{obj.time_7.nsec}> vs <288321500>"
512
512
  end
513
513
 
514
514
  it 'time(2)' do
515
- skip 'time() not supported in this protocal version' unless connection_dblib_73?
515
+ skip 'time() not supported in this protocol version' unless connection_dblib_73?
516
516
  col = column('time_2')
517
- col.sql_type.must_equal 'time(2)'
518
- col.type.must_equal :time
519
- col.null.must_equal true
520
- col.default.must_be_nil
521
- col.default_function.must_be_nil
522
- type = connection.lookup_cast_type_from_column(col)
523
- type.must_be_instance_of Type::Time
524
- type.limit.must_be_nil
525
- type.precision.must_equal 2
526
- type.scale.must_be_nil
517
+ _(col.sql_type).must_equal 'time(2)'
518
+ _(col.type).must_equal :time
519
+ _(col.null).must_equal true
520
+ _(col.default).must_be_nil
521
+ _(col.default_function).must_be_nil
522
+ type = connection.lookup_cast_type_from_column(col)
523
+ _(type).must_be_instance_of Type::Time
524
+ _(type.limit).must_be_nil
525
+ _(type.precision).must_equal 2
526
+ _(type.scale).must_be_nil
527
527
  # Always uses TinyTDS/Windows 2000-01-01 convention too.
528
528
  obj.time_2 = Time.utc(2015, 01, 10, 15, 45, 00, 0)
529
- obj.time_2.must_equal Time.utc(2000, 01, 01, 15, 45, 00, 0)
529
+ _(obj.time_2).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 0)
530
530
  obj.save! ; obj.reload
531
- obj.time_2.must_equal Time.utc(2000, 01, 01, 15, 45, 00, 0)
531
+ _(obj.time_2).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 0)
532
532
  # Time's #usec precision (barely in 2 precision equal to 0.03 seconds)
533
533
  obj.time_2 = Time.utc(2000, 01, 01, 15, 45, 00, 30000)
534
- obj.time_2.must_equal Time.utc(2000, 01, 01, 15, 45, 00, 30000), "Microseconds were <#{obj.time_2.usec}> vs <30000>"
534
+ _(obj.time_2).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 30000), "Microseconds were <#{obj.time_2.usec}> vs <30000>"
535
535
  obj.save! ; obj.reload
536
- obj.time_2.must_equal Time.utc(2000, 01, 01, 15, 45, 00, 30000), "Microseconds were <#{obj.time_2.usec}> vs <30000>"
536
+ _(obj.time_2).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 30000), "Microseconds were <#{obj.time_2.usec}> vs <30000>"
537
537
  # Time's #usec precision (below 2 precision)
538
538
  obj.time_2 = Time.utc(2000, 01, 01, 15, 45, 00, 4000)
539
- obj.time_2.must_equal Time.utc(2000, 01, 01, 15, 45, 00, 0), "Microseconds were <#{obj.time_2.usec}> vs <0>"
539
+ _(obj.time_2).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 0), "Microseconds were <#{obj.time_2.usec}> vs <0>"
540
540
  obj.save! ; obj.reload
541
- obj.time_2.must_equal Time.utc(2000, 01, 01, 15, 45, 00, 0), "Microseconds were <#{obj.time_2.usec}> vs <0>"
541
+ _(obj.time_2).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 0), "Microseconds were <#{obj.time_2.usec}> vs <0>"
542
+ end
543
+
544
+ it 'time using default precision' do
545
+ skip 'time() not supported in this protocol version' unless connection_dblib_73?
546
+ col = column('time_default')
547
+ _(col.sql_type).must_equal 'time(7)'
548
+ _(col.type).must_equal :time
549
+ _(col.null).must_equal true
550
+ _(col.default).must_equal Time.utc(1900, 01, 01, 15, 03, 42, Rational(62197800, 1000)), "Nanoseconds were <#{col.default.nsec}> vs <62197800>"
551
+ _(col.default_function).must_be_nil
552
+ type = connection.lookup_cast_type_from_column(col)
553
+ _(type).must_be_instance_of Type::Time
554
+ _(type.limit).must_be_nil
555
+ _(type.precision).must_equal 7
556
+ _(type.scale).must_be_nil
557
+ # Time's #usec precision (low micro)
558
+ obj.time_default = Time.utc(2000, 01, 01, 15, 45, 00, 300)
559
+ _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Microseconds were <#{obj.time_default.usec}> vs <0>"
560
+ _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Nanoseconds were <#{obj.time_default.nsec}> vs <300>"
561
+ obj.save! ; obj.reload
562
+ _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Microseconds were <#{obj.time_default.usec}> vs <0>"
563
+ _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Nanoseconds were <#{obj.time_default.nsec}> vs <300>"
564
+ # Time's #usec precision (high micro)
565
+ obj.time_default = Time.utc(2000, 01, 01, 15, 45, 00, 234567)
566
+ _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 234567), "Microseconds were <#{obj.time_default.usec}> vs <234567>"
567
+ obj.save! ; obj.reload
568
+ _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 234567), "Microseconds were <#{obj.time_default.usec}> vs <234567>"
569
+ # Time's #usec precision (high nano rounded)
570
+ obj.time_default = Time.utc(2000, 01, 01, 15, 45, 00, Rational(288321545, 1000))
571
+ _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, Rational(288321500, 1000)), "Nanoseconds were <#{obj.time_default.nsec}> vs <288321500>"
572
+ obj.save! ; obj.reload
573
+ _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, Rational(288321500, 1000)), "Nanoseconds were <#{obj.time_default.nsec}> vs <288321500>"
542
574
  end
543
575
 
544
576
  # Character Strings
545
577
 
546
578
  it 'char(10)' do
547
579
  col = column('char_10')
548
- col.sql_type.must_equal 'char(10)'
549
- col.type.must_equal :char
550
- col.null.must_equal true
551
- col.default.must_equal '1234567890'
552
- obj.char_10.must_equal '1234567890'
553
- col.default_function.must_be_nil
554
- type = connection.lookup_cast_type_from_column(col)
555
- type.must_be_instance_of Type::Char
556
- type.limit.must_equal 10
557
- type.precision.must_be_nil
558
- type.scale.must_be_nil
580
+ _(col.sql_type).must_equal 'char(10)'
581
+ _(col.type).must_equal :char
582
+ _(col.null).must_equal true
583
+ _(col.default).must_equal '1234567890'
584
+ _(obj.char_10).must_equal '1234567890'
585
+ _(col.default_function).must_be_nil
586
+ type = connection.lookup_cast_type_from_column(col)
587
+ _(type).must_be_instance_of Type::Char
588
+ _(type.limit).must_equal 10
589
+ _(type.precision).must_be_nil
590
+ _(type.scale).must_be_nil
559
591
  # Basic set and save.
560
592
  obj.char_10 = '012345'
561
- obj.char_10.strip.must_equal '012345'
593
+ _(obj.char_10.strip).must_equal '012345'
562
594
  obj.save!
563
- obj.reload.char_10.strip.must_equal '012345'
595
+ _(obj.reload.char_10.strip).must_equal '012345'
564
596
  end
565
597
 
566
598
  it 'varchar(50)' do
567
599
  col = column('varchar_50')
568
- col.sql_type.must_equal 'varchar(50)'
569
- col.type.must_equal :varchar
570
- col.null.must_equal true
571
- col.default.must_equal 'test varchar_50'
572
- obj.varchar_50.must_equal 'test varchar_50'
573
- col.default_function.must_be_nil
574
- type = connection.lookup_cast_type_from_column(col)
575
- type.must_be_instance_of Type::Varchar
576
- type.limit.must_equal 50
577
- type.precision.must_be_nil
578
- type.scale.must_be_nil
600
+ _(col.sql_type).must_equal 'varchar(50)'
601
+ _(col.type).must_equal :varchar
602
+ _(col.null).must_equal true
603
+ _(col.default).must_equal 'test varchar_50'
604
+ _(obj.varchar_50).must_equal 'test varchar_50'
605
+ _(col.default_function).must_be_nil
606
+ type = connection.lookup_cast_type_from_column(col)
607
+ _(type).must_be_instance_of Type::Varchar
608
+ _(type.limit).must_equal 50
609
+ _(type.precision).must_be_nil
610
+ _(type.scale).must_be_nil
579
611
  # Basic set and save.
580
612
  assert_obj_set_and_save :varchar_50, 'Hello World'
581
613
  end
582
614
 
583
615
  it 'varchar(max)' do
584
616
  col = column('varchar_max')
585
- col.sql_type.must_equal 'varchar(max)'
586
- col.type.must_equal :varchar_max
587
- col.null.must_equal true
588
- col.default.must_equal 'test varchar_max'
589
- obj.varchar_max.must_equal 'test varchar_max'
590
- col.default_function.must_be_nil
591
- type = connection.lookup_cast_type_from_column(col)
592
- type.must_be_instance_of Type::VarcharMax
593
- type.limit.must_equal 2_147_483_647
594
- type.precision.must_be_nil
595
- type.scale.must_be_nil
617
+ _(col.sql_type).must_equal 'varchar(max)'
618
+ _(col.type).must_equal :varchar_max
619
+ _(col.null).must_equal true
620
+ _(col.default).must_equal 'test varchar_max'
621
+ _(obj.varchar_max).must_equal 'test varchar_max'
622
+ _(col.default_function).must_be_nil
623
+ type = connection.lookup_cast_type_from_column(col)
624
+ _(type).must_be_instance_of Type::VarcharMax
625
+ _(type.limit).must_equal 2_147_483_647
626
+ _(type.precision).must_be_nil
627
+ _(type.scale).must_be_nil
596
628
  # Basic set and save.
597
629
  assert_obj_set_and_save :varchar_max, 'Hello World'
598
630
  end
599
631
 
600
632
  it 'text' do
601
633
  col = column('text')
602
- col.sql_type.must_equal 'text'
603
- col.type.must_equal :text_basic
604
- col.null.must_equal true
605
- col.default.must_equal 'test text'
606
- obj.text.must_equal 'test text'
607
- col.default_function.must_be_nil
608
- type = connection.lookup_cast_type_from_column(col)
609
- type.must_be_instance_of Type::Text
610
- type.limit.must_equal 2_147_483_647
611
- type.precision.must_be_nil
612
- type.scale.must_be_nil
634
+ _(col.sql_type).must_equal 'text'
635
+ _(col.type).must_equal :text_basic
636
+ _(col.null).must_equal true
637
+ _(col.default).must_equal 'test text'
638
+ _(obj.text).must_equal 'test text'
639
+ _(col.default_function).must_be_nil
640
+ type = connection.lookup_cast_type_from_column(col)
641
+ _(type).must_be_instance_of Type::Text
642
+ _(type.limit).must_equal 2_147_483_647
643
+ _(type.precision).must_be_nil
644
+ _(type.scale).must_be_nil
613
645
  # Basic set and save.
614
646
  assert_obj_set_and_save :text, 'Hello World'
615
647
  end
@@ -618,71 +650,71 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
618
650
 
619
651
  it 'nchar(10)' do
620
652
  col = column('nchar_10')
621
- col.sql_type.must_equal 'nchar(10)'
622
- col.type.must_equal :nchar
623
- col.null.must_equal true
624
- col.default.must_equal '12345678åå'
625
- obj.nchar_10.must_equal '12345678åå'
626
- col.default_function.must_be_nil
627
- type = connection.lookup_cast_type_from_column(col)
628
- type.must_be_instance_of Type::UnicodeChar
629
- type.limit.must_equal 10
630
- type.precision.must_be_nil
631
- type.scale.must_be_nil
653
+ _(col.sql_type).must_equal 'nchar(10)'
654
+ _(col.type).must_equal :nchar
655
+ _(col.null).must_equal true
656
+ _(col.default).must_equal '12345678åå'
657
+ _(obj.nchar_10).must_equal '12345678åå'
658
+ _(col.default_function).must_be_nil
659
+ type = connection.lookup_cast_type_from_column(col)
660
+ _(type).must_be_instance_of Type::UnicodeChar
661
+ _(type.limit).must_equal 10
662
+ _(type.precision).must_be_nil
663
+ _(type.scale).must_be_nil
632
664
  # Basic set and save.
633
665
  obj.nchar_10 = "五六"
634
- obj.nchar_10.strip.must_equal "五六"
666
+ _(obj.nchar_10.strip).must_equal "五六"
635
667
  obj.save!
636
- obj.reload.nchar_10.strip.must_equal "五六"
668
+ _(obj.reload.nchar_10.strip).must_equal "五六"
637
669
  end
638
670
 
639
671
  it 'nvarchar(50)' do
640
672
  col = column('nvarchar_50')
641
- col.sql_type.must_equal 'nvarchar(50)'
642
- col.type.must_equal :string
643
- col.null.must_equal true
644
- col.default.must_equal 'test nvarchar_50 åå'
645
- obj.nvarchar_50.must_equal 'test nvarchar_50 åå'
646
- col.default_function.must_be_nil
647
- type = connection.lookup_cast_type_from_column(col)
648
- type.must_be_instance_of Type::UnicodeVarchar
649
- type.limit.must_equal 50
650
- type.precision.must_be_nil
651
- type.scale.must_be_nil
673
+ _(col.sql_type).must_equal 'nvarchar(50)'
674
+ _(col.type).must_equal :string
675
+ _(col.null).must_equal true
676
+ _(col.default).must_equal 'test nvarchar_50 åå'
677
+ _(obj.nvarchar_50).must_equal 'test nvarchar_50 åå'
678
+ _(col.default_function).must_be_nil
679
+ type = connection.lookup_cast_type_from_column(col)
680
+ _(type).must_be_instance_of Type::UnicodeVarchar
681
+ _(type.limit).must_equal 50
682
+ _(type.precision).must_be_nil
683
+ _(type.scale).must_be_nil
652
684
  # Basic set and save.
653
685
  assert_obj_set_and_save :nvarchar_50, "一二34五六"
654
686
  end
655
687
 
656
688
  it 'nvarchar(max)' do
657
689
  col = column('nvarchar_max')
658
- col.sql_type.must_equal 'nvarchar(max)'
659
- col.type.must_equal :text
660
- col.null.must_equal true
661
- col.default.must_equal 'test nvarchar_max åå'
662
- obj.nvarchar_max.must_equal 'test nvarchar_max åå'
663
- col.default_function.must_be_nil
664
- type = connection.lookup_cast_type_from_column(col)
665
- type.must_be_instance_of Type::UnicodeVarcharMax
666
- type.limit.must_equal 2_147_483_647
667
- type.precision.must_be_nil
668
- type.scale.must_be_nil
690
+ _(col.sql_type).must_equal 'nvarchar(max)'
691
+ _(col.type).must_equal :text
692
+ _(col.null).must_equal true
693
+ _(col.default).must_equal 'test nvarchar_max åå'
694
+ _(obj.nvarchar_max).must_equal 'test nvarchar_max åå'
695
+ _(col.default_function).must_be_nil
696
+ type = connection.lookup_cast_type_from_column(col)
697
+ _(type).must_be_instance_of Type::UnicodeVarcharMax
698
+ _(type.limit).must_equal 2_147_483_647
699
+ _(type.precision).must_be_nil
700
+ _(type.scale).must_be_nil
669
701
  # Basic set and save.
670
702
  assert_obj_set_and_save :nvarchar_max, "一二34五六"
671
703
  end
672
704
 
673
705
  it 'ntext' do
674
706
  col = column('ntext')
675
- col.sql_type.must_equal 'ntext'
676
- col.type.must_equal :ntext
677
- col.null.must_equal true
678
- col.default.must_equal 'test ntext åå'
679
- obj.ntext.must_equal 'test ntext åå'
680
- col.default_function.must_be_nil
681
- type = connection.lookup_cast_type_from_column(col)
682
- type.must_be_instance_of Type::UnicodeText
683
- type.limit.must_equal 2_147_483_647
684
- type.precision.must_be_nil
685
- type.scale.must_be_nil
707
+ _(col.sql_type).must_equal 'ntext'
708
+ _(col.type).must_equal :ntext
709
+ _(col.null).must_equal true
710
+ _(col.default).must_equal 'test ntext åå'
711
+ _(obj.ntext).must_equal 'test ntext åå'
712
+ _(col.default_function).must_be_nil
713
+ type = connection.lookup_cast_type_from_column(col)
714
+ _(type).must_be_instance_of Type::UnicodeText
715
+ _(type.limit).must_equal 2_147_483_647
716
+ _(type.precision).must_be_nil
717
+ _(type.scale).must_be_nil
686
718
  # Basic set and save.
687
719
  assert_obj_set_and_save :ntext, "一二34五六"
688
720
  end
@@ -694,60 +726,60 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
694
726
 
695
727
  it 'binary(49)' do
696
728
  col = column('binary_49')
697
- col.sql_type.must_equal 'binary(49)'
698
- col.type.must_equal :binary_basic
699
- col.null.must_equal true
700
- col.default.must_be_nil
701
- col.default_function.must_be_nil
702
- type = connection.lookup_cast_type_from_column(col)
703
- type.must_be_instance_of Type::Binary
704
- type.limit.must_equal 49
705
- type.precision.must_be_nil
706
- type.scale.must_be_nil
729
+ _(col.sql_type).must_equal 'binary(49)'
730
+ _(col.type).must_equal :binary_basic
731
+ _(col.null).must_equal true
732
+ _(col.default).must_be_nil
733
+ _(col.default_function).must_be_nil
734
+ type = connection.lookup_cast_type_from_column(col)
735
+ _(type).must_be_instance_of Type::Binary
736
+ _(type.limit).must_equal 49
737
+ _(type.precision).must_be_nil
738
+ _(type.scale).must_be_nil
707
739
  # Basic set and save.
708
- binary_data.encoding.must_equal Encoding::BINARY
709
- binary_data.length.must_equal 49
740
+ _(binary_data.encoding).must_equal Encoding::BINARY
741
+ _(binary_data.length).must_equal 49
710
742
  obj.binary_49 = binary_data
711
- obj.binary_49.must_equal binary_data
743
+ _(obj.binary_49).must_equal binary_data
712
744
  obj.save!
713
- obj.reload.binary_49.must_equal binary_data
745
+ _(obj.reload.binary_49).must_equal binary_data
714
746
  end
715
747
 
716
748
  it 'varbinary(49)' do
717
749
  col = column('varbinary_49')
718
- col.sql_type.must_equal 'varbinary(49)'
719
- col.type.must_equal :varbinary
720
- col.null.must_equal true
721
- col.default.must_be_nil
722
- col.default_function.must_be_nil
723
- type = connection.lookup_cast_type_from_column(col)
724
- type.must_be_instance_of Type::Varbinary
725
- type.limit.must_equal 49
726
- type.precision.must_be_nil
727
- type.scale.must_be_nil
750
+ _(col.sql_type).must_equal 'varbinary(49)'
751
+ _(col.type).must_equal :varbinary
752
+ _(col.null).must_equal true
753
+ _(col.default).must_be_nil
754
+ _(col.default_function).must_be_nil
755
+ type = connection.lookup_cast_type_from_column(col)
756
+ _(type).must_be_instance_of Type::Varbinary
757
+ _(type.limit).must_equal 49
758
+ _(type.precision).must_be_nil
759
+ _(type.scale).must_be_nil
728
760
  # Basic set and save.
729
761
  binary_data_20 = binary_data.to(20)
730
- binary_data_20.encoding.must_equal Encoding::BINARY
762
+ _(binary_data_20.encoding).must_equal Encoding::BINARY
731
763
  obj.varbinary_49 = binary_data_20
732
- obj.varbinary_49.must_equal binary_data_20
764
+ _(obj.varbinary_49).must_equal binary_data_20
733
765
  obj.save!
734
- obj.reload.varbinary_49.must_equal binary_data_20
766
+ _(obj.reload.varbinary_49).must_equal binary_data_20
735
767
  end
736
768
 
737
769
  it 'varbinary(max)' do
738
770
  col = column('varbinary_max')
739
- col.sql_type.must_equal 'varbinary(max)'
740
- col.type.must_equal :binary
741
- col.null.must_equal true
742
- col.default.must_be_nil
743
- col.default_function.must_be_nil
744
- type = connection.lookup_cast_type_from_column(col)
745
- type.must_be_instance_of Type::VarbinaryMax
746
- type.limit.must_equal 2_147_483_647
747
- type.precision.must_be_nil
748
- type.scale.must_be_nil
771
+ _(col.sql_type).must_equal 'varbinary(max)'
772
+ _(col.type).must_equal :binary
773
+ _(col.null).must_equal true
774
+ _(col.default).must_be_nil
775
+ _(col.default_function).must_be_nil
776
+ type = connection.lookup_cast_type_from_column(col)
777
+ _(type).must_be_instance_of Type::VarbinaryMax
778
+ _(type.limit).must_equal 2_147_483_647
779
+ _(type.precision).must_be_nil
780
+ _(type.scale).must_be_nil
749
781
  # Basic set and save.
750
- binary_data.encoding.must_equal Encoding::BINARY
782
+ _(binary_data.encoding).must_equal Encoding::BINARY
751
783
  assert_obj_set_and_save :varbinary_max, binary_data
752
784
  end
753
785
 
@@ -755,43 +787,43 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
755
787
 
756
788
  it 'uniqueidentifier' do
757
789
  col = column('uniqueidentifier')
758
- col.sql_type.must_equal 'uniqueidentifier'
759
- col.type.must_equal :uuid
760
- col.null.must_equal true
761
- col.default.must_be_nil
762
- col.default_function.must_equal 'newid()'
763
- type = connection.lookup_cast_type_from_column(col)
764
- type.must_be_instance_of Type::Uuid
765
- type.limit.must_be_nil
766
- type.precision.must_be_nil
767
- type.scale.must_be_nil
790
+ _(col.sql_type).must_equal 'uniqueidentifier'
791
+ _(col.type).must_equal :uuid
792
+ _(col.null).must_equal true
793
+ _(col.default).must_be_nil
794
+ _(col.default_function).must_equal 'newid()'
795
+ type = connection.lookup_cast_type_from_column(col)
796
+ _(type).must_be_instance_of Type::Uuid
797
+ _(type.limit).must_be_nil
798
+ _(type.precision).must_be_nil
799
+ _(type.scale).must_be_nil
768
800
  # Basic set and save.
769
801
  obj.uniqueidentifier = "this will not qualify as valid"
770
- obj.uniqueidentifier.must_be_nil
802
+ _(obj.uniqueidentifier).must_be_nil
771
803
  obj.save! ; obj.reload
772
- obj.uniqueidentifier.must_match Type::Uuid::ACCEPTABLE_UUID
804
+ _(obj.uniqueidentifier).must_match Type::Uuid::ACCEPTABLE_UUID
773
805
  obj.uniqueidentifier = "6F9619FF-8B86-D011-B42D-00C04FC964FF"
774
- obj.uniqueidentifier.must_equal "6F9619FF-8B86-D011-B42D-00C04FC964FF"
806
+ _(obj.uniqueidentifier).must_equal "6F9619FF-8B86-D011-B42D-00C04FC964FF"
775
807
  obj.save! ; obj.reload
776
- obj.uniqueidentifier.must_equal "6F9619FF-8B86-D011-B42D-00C04FC964FF"
808
+ _(obj.uniqueidentifier).must_equal "6F9619FF-8B86-D011-B42D-00C04FC964FF"
777
809
  end
778
810
 
779
811
  it 'timestamp' do
780
812
  col = column('timestamp')
781
- col.sql_type.must_equal 'timestamp'
782
- col.type.must_equal :ss_timestamp
783
- col.null.must_equal true
784
- col.default.must_be_nil
785
- col.default_function.must_be_nil
786
- type = connection.lookup_cast_type_from_column(col)
787
- type.must_be_instance_of Type::Timestamp
788
- type.limit.must_be_nil
789
- type.precision.must_be_nil
790
- type.scale.must_be_nil
813
+ _(col.sql_type).must_equal 'timestamp'
814
+ _(col.type).must_equal :ss_timestamp
815
+ _(col.null).must_equal true
816
+ _(col.default).must_be_nil
817
+ _(col.default_function).must_be_nil
818
+ type = connection.lookup_cast_type_from_column(col)
819
+ _(type).must_be_instance_of Type::Timestamp
820
+ _(type.limit).must_be_nil
821
+ _(type.precision).must_be_nil
822
+ _(type.scale).must_be_nil
791
823
  # Basic read.
792
- obj.timestamp.must_be_nil
824
+ _(obj.timestamp).must_be_nil
793
825
  obj.save! ; obj.reload
794
- obj.timestamp.must_match %r|\000|
826
+ _(obj.timestamp).must_match %r|\000|
795
827
  obj.timestamp
796
828
  # Can set another attribute
797
829
  obj.uniqueidentifier = "6F9619FF-8B86-D011-B42D-00C04FC964FF"
@@ -801,7 +833,7 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
801
833
  it 'does not mark object as changed after save' do
802
834
  obj.save!
803
835
  obj.attributes
804
- obj.changed?.must_equal false
836
+ _(obj.changed?).must_equal false
805
837
  end
806
838
 
807
839
  end