activerecord-sqlserver-adapter 6.0.0.rc1 → 6.1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +26 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +29 -0
  5. data/CHANGELOG.md +18 -23
  6. data/Gemfile +11 -5
  7. data/Guardfile +9 -8
  8. data/README.md +32 -3
  9. data/RUNNING_UNIT_TESTS.md +1 -1
  10. data/Rakefile +12 -16
  11. data/VERSION +1 -1
  12. data/activerecord-sqlserver-adapter.gemspec +4 -4
  13. data/lib/active_record/connection_adapters/sqlserver/core_ext/active_record.rb +0 -4
  14. data/lib/active_record/connection_adapters/sqlserver/core_ext/attribute_methods.rb +1 -4
  15. data/lib/active_record/connection_adapters/sqlserver/core_ext/calculations.rb +3 -13
  16. data/lib/active_record/connection_adapters/sqlserver/core_ext/explain.rb +8 -5
  17. data/lib/active_record/connection_adapters/sqlserver/core_ext/finder_methods.rb +2 -3
  18. data/lib/active_record/connection_adapters/sqlserver/core_ext/query_methods.rb +2 -3
  19. data/lib/active_record/connection_adapters/sqlserver/database_limits.rb +0 -4
  20. data/lib/active_record/connection_adapters/sqlserver/database_statements.rb +58 -43
  21. data/lib/active_record/connection_adapters/sqlserver/database_tasks.rb +7 -12
  22. data/lib/active_record/connection_adapters/sqlserver/errors.rb +0 -3
  23. data/lib/active_record/connection_adapters/sqlserver/quoting.rb +15 -15
  24. data/lib/active_record/connection_adapters/sqlserver/schema_creation.rb +22 -3
  25. data/lib/active_record/connection_adapters/sqlserver/schema_dumper.rb +16 -10
  26. data/lib/active_record/connection_adapters/sqlserver/schema_statements.rb +131 -105
  27. data/lib/active_record/connection_adapters/sqlserver/showplan.rb +6 -8
  28. data/lib/active_record/connection_adapters/sqlserver/showplan/printer_table.rb +2 -2
  29. data/lib/active_record/connection_adapters/sqlserver/showplan/printer_xml.rb +1 -1
  30. data/lib/active_record/connection_adapters/sqlserver/sql_type_metadata.rb +25 -7
  31. data/lib/active_record/connection_adapters/sqlserver/table_definition.rb +1 -5
  32. data/lib/active_record/connection_adapters/sqlserver/transaction.rb +6 -10
  33. data/lib/active_record/connection_adapters/sqlserver/type.rb +36 -35
  34. data/lib/active_record/connection_adapters/sqlserver/type/big_integer.rb +0 -2
  35. data/lib/active_record/connection_adapters/sqlserver/type/binary.rb +0 -2
  36. data/lib/active_record/connection_adapters/sqlserver/type/boolean.rb +0 -2
  37. data/lib/active_record/connection_adapters/sqlserver/type/char.rb +2 -2
  38. data/lib/active_record/connection_adapters/sqlserver/type/data.rb +0 -2
  39. data/lib/active_record/connection_adapters/sqlserver/type/date.rb +2 -3
  40. data/lib/active_record/connection_adapters/sqlserver/type/datetime.rb +2 -3
  41. data/lib/active_record/connection_adapters/sqlserver/type/datetime2.rb +0 -2
  42. data/lib/active_record/connection_adapters/sqlserver/type/datetimeoffset.rb +0 -2
  43. data/lib/active_record/connection_adapters/sqlserver/type/decimal.rb +0 -2
  44. data/lib/active_record/connection_adapters/sqlserver/type/decimal_without_scale.rb +22 -0
  45. data/lib/active_record/connection_adapters/sqlserver/type/float.rb +0 -2
  46. data/lib/active_record/connection_adapters/sqlserver/type/integer.rb +0 -2
  47. data/lib/active_record/connection_adapters/sqlserver/type/json.rb +0 -1
  48. data/lib/active_record/connection_adapters/sqlserver/type/money.rb +0 -2
  49. data/lib/active_record/connection_adapters/sqlserver/type/real.rb +0 -2
  50. data/lib/active_record/connection_adapters/sqlserver/type/small_integer.rb +0 -2
  51. data/lib/active_record/connection_adapters/sqlserver/type/small_money.rb +0 -2
  52. data/lib/active_record/connection_adapters/sqlserver/type/smalldatetime.rb +0 -2
  53. data/lib/active_record/connection_adapters/sqlserver/type/string.rb +0 -2
  54. data/lib/active_record/connection_adapters/sqlserver/type/text.rb +0 -2
  55. data/lib/active_record/connection_adapters/sqlserver/type/time.rb +2 -3
  56. data/lib/active_record/connection_adapters/sqlserver/type/time_value_fractional.rb +6 -9
  57. data/lib/active_record/connection_adapters/sqlserver/type/timestamp.rb +0 -2
  58. data/lib/active_record/connection_adapters/sqlserver/type/tiny_integer.rb +0 -2
  59. data/lib/active_record/connection_adapters/sqlserver/type/unicode_char.rb +1 -3
  60. data/lib/active_record/connection_adapters/sqlserver/type/unicode_string.rb +0 -2
  61. data/lib/active_record/connection_adapters/sqlserver/type/unicode_text.rb +0 -2
  62. data/lib/active_record/connection_adapters/sqlserver/type/unicode_varchar.rb +0 -2
  63. data/lib/active_record/connection_adapters/sqlserver/type/unicode_varchar_max.rb +0 -2
  64. data/lib/active_record/connection_adapters/sqlserver/type/uuid.rb +1 -2
  65. data/lib/active_record/connection_adapters/sqlserver/type/varbinary.rb +1 -3
  66. data/lib/active_record/connection_adapters/sqlserver/type/varbinary_max.rb +0 -2
  67. data/lib/active_record/connection_adapters/sqlserver/type/varchar.rb +1 -3
  68. data/lib/active_record/connection_adapters/sqlserver/type/varchar_max.rb +0 -2
  69. data/lib/active_record/connection_adapters/sqlserver/utils.rb +8 -11
  70. data/lib/active_record/connection_adapters/sqlserver/version.rb +0 -2
  71. data/lib/active_record/connection_adapters/sqlserver_adapter.rb +170 -136
  72. data/lib/active_record/connection_adapters/sqlserver_column.rb +16 -1
  73. data/lib/active_record/sqlserver_base.rb +9 -15
  74. data/lib/active_record/tasks/sqlserver_database_tasks.rb +36 -39
  75. data/lib/activerecord-sqlserver-adapter.rb +1 -1
  76. data/lib/arel/visitors/sqlserver.rb +126 -50
  77. data/lib/arel_sqlserver.rb +2 -2
  78. data/test/cases/adapter_test_sqlserver.rb +203 -190
  79. data/test/cases/change_column_collation_test_sqlserver.rb +33 -0
  80. data/test/cases/change_column_null_test_sqlserver.rb +12 -12
  81. data/test/cases/coerced_tests.rb +656 -318
  82. data/test/cases/column_test_sqlserver.rb +285 -284
  83. data/test/cases/connection_test_sqlserver.rb +15 -20
  84. data/test/cases/disconnected_test_sqlserver.rb +39 -0
  85. data/test/cases/execute_procedure_test_sqlserver.rb +26 -19
  86. data/test/cases/fetch_test_sqlserver.rb +14 -22
  87. data/test/cases/fully_qualified_identifier_test_sqlserver.rb +12 -18
  88. data/test/cases/helper_sqlserver.rb +13 -15
  89. data/test/cases/in_clause_test_sqlserver.rb +36 -9
  90. data/test/cases/index_test_sqlserver.rb +13 -15
  91. data/test/cases/json_test_sqlserver.rb +23 -25
  92. data/test/cases/lateral_test_sqlserver.rb +35 -0
  93. data/test/cases/migration_test_sqlserver.rb +71 -26
  94. data/test/cases/optimizer_hints_test_sqlserver.rb +72 -0
  95. data/test/cases/order_test_sqlserver.rb +57 -53
  96. data/test/cases/pessimistic_locking_test_sqlserver.rb +25 -33
  97. data/test/cases/primary_keys_test_sqlserver.rb +103 -0
  98. data/test/cases/rake_test_sqlserver.rb +33 -46
  99. data/test/cases/schema_dumper_test_sqlserver.rb +121 -108
  100. data/test/cases/schema_test_sqlserver.rb +18 -26
  101. data/test/cases/scratchpad_test_sqlserver.rb +2 -4
  102. data/test/cases/showplan_test_sqlserver.rb +24 -33
  103. data/test/cases/specific_schema_test_sqlserver.rb +66 -65
  104. data/test/cases/transaction_test_sqlserver.rb +16 -19
  105. data/test/cases/trigger_test_sqlserver.rb +12 -12
  106. data/test/cases/utils_test_sqlserver.rb +68 -70
  107. data/test/cases/uuid_test_sqlserver.rb +11 -13
  108. data/test/debug.rb +6 -6
  109. data/test/migrations/create_clients_and_change_column_collation.rb +19 -0
  110. data/test/migrations/create_clients_and_change_column_null.rb +1 -1
  111. data/test/migrations/transaction_table/1_table_will_never_be_created.rb +2 -4
  112. data/test/models/sqlserver/booking.rb +1 -1
  113. data/test/models/sqlserver/customers_view.rb +1 -1
  114. data/test/models/sqlserver/dollar_table_name.rb +1 -1
  115. data/test/models/sqlserver/edge_schema.rb +1 -3
  116. data/test/models/sqlserver/fk_has_fk.rb +1 -1
  117. data/test/models/sqlserver/fk_has_pk.rb +1 -1
  118. data/test/models/sqlserver/natural_pk_data.rb +2 -2
  119. data/test/models/sqlserver/natural_pk_int_data.rb +1 -1
  120. data/test/models/sqlserver/no_pk_data.rb +1 -1
  121. data/test/models/sqlserver/object_default.rb +1 -1
  122. data/test/models/sqlserver/quoted_table.rb +2 -2
  123. data/test/models/sqlserver/quoted_view_1.rb +1 -1
  124. data/test/models/sqlserver/quoted_view_2.rb +1 -1
  125. data/test/models/sqlserver/sst_memory.rb +1 -1
  126. data/test/models/sqlserver/sst_string_collation.rb +3 -0
  127. data/test/models/sqlserver/string_default.rb +1 -1
  128. data/test/models/sqlserver/string_defaults_big_view.rb +1 -1
  129. data/test/models/sqlserver/string_defaults_view.rb +1 -1
  130. data/test/models/sqlserver/tinyint_pk.rb +1 -1
  131. data/test/models/sqlserver/trigger.rb +2 -2
  132. data/test/models/sqlserver/trigger_history.rb +1 -1
  133. data/test/models/sqlserver/upper.rb +1 -1
  134. data/test/models/sqlserver/uppered.rb +1 -1
  135. data/test/models/sqlserver/uuid.rb +1 -1
  136. data/test/schema/sqlserver_specific_schema.rb +36 -21
  137. data/test/support/coerceable_test_sqlserver.rb +1 -4
  138. data/test/support/connection_reflection.rb +1 -2
  139. data/test/support/core_ext/query_cache.rb +1 -1
  140. data/test/support/load_schema_sqlserver.rb +3 -5
  141. data/test/support/marshal_compatibility_fixtures/SQLServer/rails_6_0_topic.dump +0 -0
  142. data/test/support/marshal_compatibility_fixtures/SQLServer/rails_6_0_topic_associations.dump +0 -0
  143. data/test/support/minitest_sqlserver.rb +1 -1
  144. data/test/support/paths_sqlserver.rb +9 -11
  145. data/test/support/rake_helpers.rb +12 -10
  146. data/test/support/sql_counter_sqlserver.rb +14 -16
  147. data/test/support/test_in_memory_oltp.rb +7 -7
  148. metadata +31 -11
  149. data/.travis.yml +0 -23
@@ -1,22 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'cases/helper_sqlserver'
3
+ require "cases/helper_sqlserver"
4
4
 
5
5
  class ColumnTestSQLServer < ActiveRecord::TestCase
6
-
7
- it '#table_name' do
8
- assert SSTestDatatype.columns.all? { |c| c.table_name == 'sst_datatypes' }
9
- assert SSTestCustomersView.columns.all? { |c| c.table_name == 'customers' }
6
+ it "#table_name" do
7
+ assert SSTestDatatype.columns.all? { |c| c.table_name == "sst_datatypes" }
8
+ assert SSTestCustomersView.columns.all? { |c| c.table_name == "customers" }
10
9
  end
11
10
 
12
- describe 'ActiveRecord::ConnectionAdapters::SQLServer::Type' do
13
-
11
+ describe "ActiveRecord::ConnectionAdapters::SQLServer::Type" do
14
12
  let(:obj) { SSTestDatatype.new }
15
13
 
16
14
  Type = ActiveRecord::ConnectionAdapters::SQLServer::Type
17
15
 
18
- def new_obj ; SSTestDatatype.new ; end
19
- def column(name) ; SSTestDatatype.columns_hash[name] ; end
16
+ def new_obj; SSTestDatatype.new; end
17
+
18
+ def column(name); SSTestDatatype.columns_hash[name]; end
19
+
20
20
  def assert_obj_set_and_save(attribute, value)
21
21
  obj.send :"#{attribute}=", value
22
22
  _(obj.send(attribute)).must_equal value
@@ -28,15 +28,15 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
28
28
 
29
29
  # Exact Numerics
30
30
 
31
- it 'int(4) PRIMARY KEY' do
32
- col = column('id')
33
- _(col.sql_type).must_equal 'int(4)'
31
+ it "int(4) PRIMARY KEY" do
32
+ col = column("id")
33
+ _(col.sql_type).must_equal "int(4)"
34
34
  _(col.null).must_equal false
35
35
  end
36
36
 
37
- it 'bigint(8)' do
38
- col = column('bigint')
39
- _(col.sql_type).must_equal 'bigint(8)'
37
+ it "bigint(8)" do
38
+ col = column("bigint")
39
+ _(col.sql_type).must_equal "bigint(8)"
40
40
  _(col.type).must_equal :integer
41
41
  _(col.null).must_equal true
42
42
  _(col.default).must_equal 42
@@ -49,9 +49,9 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
49
49
  assert_obj_set_and_save :bigint, 9_223_372_036_854_775_807
50
50
  end
51
51
 
52
- it 'int(4)' do
53
- col = column('int')
54
- _(col.sql_type).must_equal 'int(4)'
52
+ it "int(4)" do
53
+ col = column("int")
54
+ _(col.sql_type).must_equal "int(4)"
55
55
  _(col.type).must_equal :integer
56
56
  _(col.null).must_equal true
57
57
  _(col.default).must_equal 42
@@ -64,9 +64,9 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
64
64
  assert_obj_set_and_save :int, 2_147_483_647
65
65
  end
66
66
 
67
- it 'smallint(2)' do
68
- col = column('smallint')
69
- _(col.sql_type).must_equal 'smallint(2)'
67
+ it "smallint(2)" do
68
+ col = column("smallint")
69
+ _(col.sql_type).must_equal "smallint(2)"
70
70
  _(col.type).must_equal :integer
71
71
  _(col.null).must_equal true
72
72
  _(col.default).must_equal 42
@@ -79,9 +79,9 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
79
79
  assert_obj_set_and_save :smallint, 32_767
80
80
  end
81
81
 
82
- it 'tinyint(1)' do
83
- col = column('tinyint')
84
- _(col.sql_type).must_equal 'tinyint(1)'
82
+ it "tinyint(1)" do
83
+ col = column("tinyint")
84
+ _(col.sql_type).must_equal "tinyint(1)"
85
85
  _(col.type).must_equal :integer
86
86
  _(col.null).must_equal true
87
87
  _(col.default).must_equal 42
@@ -94,220 +94,223 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
94
94
  assert_obj_set_and_save :tinyint, 255
95
95
  end
96
96
 
97
- it 'bit' do
98
- col = column('bit')
99
- _(col.sql_type).must_equal 'bit'
97
+ it "bit" do
98
+ col = column("bit")
99
+ _(col.sql_type).must_equal "bit"
100
100
  _(col.type).must_equal :boolean
101
101
  _(col.null).must_equal true
102
102
  _(col.default).must_equal true
103
103
  _(obj.bit).must_equal true
104
104
  _(col.default_function).must_be_nil
105
105
  type = connection.lookup_cast_type_from_column(col)
106
- _(type).must_be_instance_of Type::Boolean
106
+ _(type).must_be_instance_of Type::Boolean
107
107
  _(type.limit).must_be_nil
108
108
  obj.bit = 0
109
109
  _(obj.bit).must_equal false
110
110
  obj.save!
111
111
  _(obj.reload.bit).must_equal false
112
- obj.bit = '1'
112
+ obj.bit = "1"
113
113
  _(obj.bit).must_equal true
114
114
  obj.save!
115
115
  _(obj.reload.bit).must_equal true
116
116
  end
117
117
 
118
- it 'decimal(9,2)' do
119
- col = column('decimal_9_2')
120
- _(col.sql_type).must_equal 'decimal(9,2)'
118
+ it "decimal(9,2)" do
119
+ col = column("decimal_9_2")
120
+ _(col.sql_type).must_equal "decimal(9,2)"
121
121
  _(col.type).must_equal :decimal
122
122
  _(col.null).must_equal true
123
- _(col.default).must_equal BigDecimal('12345.01')
124
- _(obj.decimal_9_2).must_equal BigDecimal('12345.01')
123
+ _(col.default).must_equal BigDecimal("12345.01")
124
+ _(obj.decimal_9_2).must_equal BigDecimal("12345.01")
125
125
  _(col.default_function).must_be_nil
126
126
  type = connection.lookup_cast_type_from_column(col)
127
- _(type).must_be_instance_of Type::Decimal
127
+ _(type).must_be_instance_of Type::Decimal
128
128
  _(type.limit).must_be_nil
129
129
  _(type.precision).must_equal 9
130
130
  _(type.scale).must_equal 2
131
- obj.decimal_9_2 = '1234567.8901'
132
- _(obj.decimal_9_2).must_equal BigDecimal('1234567.89')
131
+ obj.decimal_9_2 = "1234567.8901"
132
+ _(obj.decimal_9_2).must_equal BigDecimal("1234567.89")
133
133
  obj.save!
134
- _(obj.reload.decimal_9_2).must_equal BigDecimal('1234567.89')
134
+ _(obj.reload.decimal_9_2).must_equal BigDecimal("1234567.89")
135
135
  end
136
136
 
137
- it 'decimal(16,4)' do
138
- col = column('decimal_16_4')
139
- _(col.sql_type).must_equal 'decimal(16,4)'
140
- _(col.default).must_equal BigDecimal('1234567.89')
141
- _(obj.decimal_16_4).must_equal BigDecimal('1234567.89')
137
+ it "decimal(16,4)" do
138
+ col = column("decimal_16_4")
139
+ _(col.sql_type).must_equal "decimal(16,4)"
140
+ _(col.default).must_equal BigDecimal("1234567.89")
141
+ _(obj.decimal_16_4).must_equal BigDecimal("1234567.89")
142
142
  _(col.default_function).must_be_nil
143
143
  type = connection.lookup_cast_type_from_column(col)
144
144
  _(type.precision).must_equal 16
145
145
  _(type.scale).must_equal 4
146
- obj.decimal_16_4 = '1234567.8901001'
147
- _(obj.decimal_16_4).must_equal BigDecimal('1234567.8901')
146
+ obj.decimal_16_4 = "1234567.8901001"
147
+ _(obj.decimal_16_4).must_equal BigDecimal("1234567.8901")
148
148
  obj.save!
149
- _(obj.reload.decimal_16_4).must_equal BigDecimal('1234567.8901')
149
+ _(obj.reload.decimal_16_4).must_equal BigDecimal("1234567.8901")
150
150
  end
151
151
 
152
- it 'numeric(18,0)' do
153
- col = column('numeric_18_0')
154
- _(col.sql_type).must_equal 'numeric(18,0)'
152
+ it "numeric(18,0)" do
153
+ col = column("numeric_18_0")
154
+ _(col.sql_type).must_equal "numeric(18,0)"
155
155
  _(col.type).must_equal :decimal
156
156
  _(col.null).must_equal true
157
- _(col.default).must_equal BigDecimal('191')
158
- _(obj.numeric_18_0).must_equal BigDecimal('191')
157
+ _(col.default).must_equal BigDecimal("191")
158
+ _(obj.numeric_18_0).must_equal BigDecimal("191")
159
159
  _(col.default_function).must_be_nil
160
+
160
161
  type = connection.lookup_cast_type_from_column(col)
161
- _(type).must_be_instance_of Type::Decimal
162
+ _(type).must_be_instance_of Type::DecimalWithoutScale
162
163
  _(type.limit).must_be_nil
163
164
  _(type.precision).must_equal 18
164
- _(type.scale).must_equal 0
165
- obj.numeric_18_0 = '192.1'
166
- _(obj.numeric_18_0).must_equal BigDecimal('192')
165
+ _(type.scale).must_be_nil
166
+
167
+ obj.numeric_18_0 = "192.1"
168
+ _(obj.numeric_18_0).must_equal BigDecimal("192")
169
+
167
170
  obj.save!
168
- _(obj.reload.numeric_18_0).must_equal BigDecimal('192')
171
+ _(obj.reload.numeric_18_0).must_equal BigDecimal("192")
169
172
  end
170
173
 
171
- it 'numeric(36,2)' do
172
- col = column('numeric_36_2')
173
- _(col.sql_type).must_equal 'numeric(36,2)'
174
+ it "numeric(36,2)" do
175
+ col = column("numeric_36_2")
176
+ _(col.sql_type).must_equal "numeric(36,2)"
174
177
  _(col.type).must_equal :decimal
175
178
  _(col.null).must_equal true
176
- _(col.default).must_equal BigDecimal('12345678901234567890.01')
177
- _(obj.numeric_36_2).must_equal BigDecimal('12345678901234567890.01')
179
+ _(col.default).must_equal BigDecimal("12345678901234567890.01")
180
+ _(obj.numeric_36_2).must_equal BigDecimal("12345678901234567890.01")
178
181
  _(col.default_function).must_be_nil
179
182
  type = connection.lookup_cast_type_from_column(col)
180
- _(type).must_be_instance_of Type::Decimal
183
+ _(type).must_be_instance_of Type::Decimal
181
184
  _(type.limit).must_be_nil
182
185
  _(type.precision).must_equal 36
183
186
  _(type.scale).must_equal 2
184
- obj.numeric_36_2 = '192.123'
185
- _(obj.numeric_36_2).must_equal BigDecimal('192.12')
187
+ obj.numeric_36_2 = "192.123"
188
+ _(obj.numeric_36_2).must_equal BigDecimal("192.12")
186
189
  obj.save!
187
- _(obj.reload.numeric_36_2).must_equal BigDecimal('192.12')
190
+ _(obj.reload.numeric_36_2).must_equal BigDecimal("192.12")
188
191
  end
189
192
 
190
- it 'money' do
191
- col = column('money')
192
- _(col.sql_type).must_equal 'money'
193
+ it "money" do
194
+ col = column("money")
195
+ _(col.sql_type).must_equal "money"
193
196
  _(col.type).must_equal :money
194
197
  _(col.null).must_equal true
195
- _(col.default).must_equal BigDecimal('4.20')
196
- _(obj.money).must_equal BigDecimal('4.20')
198
+ _(col.default).must_equal BigDecimal("4.20")
199
+ _(obj.money).must_equal BigDecimal("4.20")
197
200
  _(col.default_function).must_be_nil
198
201
  type = connection.lookup_cast_type_from_column(col)
199
- _(type).must_be_instance_of Type::Money
202
+ _(type).must_be_instance_of Type::Money
200
203
  _(type.limit).must_be_nil
201
204
  _(type.precision).must_equal 19
202
205
  _(type.scale).must_equal 4
203
- obj.money = '922337203685477.58061'
204
- _(obj.money).must_equal BigDecimal('922337203685477.5806')
206
+ obj.money = "922337203685477.58061"
207
+ _(obj.money).must_equal BigDecimal("922337203685477.5806")
205
208
  obj.save!
206
- _(obj.reload.money).must_equal BigDecimal('922337203685477.5806')
209
+ _(obj.reload.money).must_equal BigDecimal("922337203685477.5806")
207
210
  end
208
211
 
209
- it 'smallmoney' do
210
- col = column('smallmoney')
211
- _(col.sql_type).must_equal 'smallmoney'
212
+ it "smallmoney" do
213
+ col = column("smallmoney")
214
+ _(col.sql_type).must_equal "smallmoney"
212
215
  _(col.type).must_equal :smallmoney
213
216
  _(col.null).must_equal true
214
- _(col.default).must_equal BigDecimal('4.20')
215
- _(obj.smallmoney).must_equal BigDecimal('4.20')
217
+ _(col.default).must_equal BigDecimal("4.20")
218
+ _(obj.smallmoney).must_equal BigDecimal("4.20")
216
219
  _(col.default_function).must_be_nil
217
220
  type = connection.lookup_cast_type_from_column(col)
218
- _(type).must_be_instance_of Type::SmallMoney
221
+ _(type).must_be_instance_of Type::SmallMoney
219
222
  _(type.limit).must_be_nil
220
223
  _(type.precision).must_equal 10
221
224
  _(type.scale).must_equal 4
222
- obj.smallmoney = '214748.36461'
223
- _(obj.smallmoney).must_equal BigDecimal('214748.3646')
225
+ obj.smallmoney = "214748.36461"
226
+ _(obj.smallmoney).must_equal BigDecimal("214748.3646")
224
227
  obj.save!
225
- _(obj.reload.smallmoney).must_equal BigDecimal('214748.3646')
228
+ _(obj.reload.smallmoney).must_equal BigDecimal("214748.3646")
226
229
  end
227
230
 
228
231
  # Approximate Numerics
229
232
  # Float limits are adjusted to 24 or 53 by the database as per http://msdn.microsoft.com/en-us/library/ms173773.aspx
230
233
  # Floats with a limit of <= 24 are reduced to reals by sqlserver on creation.
231
234
 
232
- it 'float' do
233
- col = column('float')
234
- _(col.sql_type).must_equal 'float'
235
+ it "float" do
236
+ col = column("float")
237
+ _(col.sql_type).must_equal "float"
235
238
  _(col.type).must_equal :float
236
239
  _(col.null).must_equal true
237
240
  _(col.default).must_equal 123.00000001
238
241
  _(obj.float).must_equal 123.00000001
239
242
  _(col.default_function).must_be_nil
240
243
  type = connection.lookup_cast_type_from_column(col)
241
- _(type).must_be_instance_of Type::Float
244
+ _(type).must_be_instance_of Type::Float
242
245
  _(type.limit).must_be_nil
243
246
  _(type.precision).must_be_nil
244
247
  _(type.scale).must_be_nil
245
- obj.float = '214748.36461'
246
- _(obj.float).must_equal 214748.36461
248
+ obj.float = "214748.36461"
249
+ _(obj.float).must_equal 214748.36461
247
250
  obj.save!
248
251
  _(obj.reload.float).must_equal 214748.36461
249
252
  end
250
253
 
251
- it 'real' do
252
- col = column('real')
253
- _(col.sql_type).must_equal 'real'
254
+ it "real" do
255
+ col = column("real")
256
+ _(col.sql_type).must_equal "real"
254
257
  _(col.type).must_equal :real
255
258
  _(col.null).must_equal true
256
259
  _(col.default).must_be_close_to 123.45, 0.01
257
260
  _(obj.real).must_be_close_to 123.45, 0.01
258
261
  _(col.default_function).must_be_nil
259
262
  type = connection.lookup_cast_type_from_column(col)
260
- _(type).must_be_instance_of Type::Real
263
+ _(type).must_be_instance_of Type::Real
261
264
  _(type.limit).must_be_nil
262
265
  _(type.precision).must_be_nil
263
266
  _(type.scale).must_be_nil
264
- obj.real = '214748.36461'
265
- _(obj.real).must_be_close_to 214748.36461, 0.01
267
+ obj.real = "214748.36461"
268
+ _(obj.real).must_be_close_to 214748.36461, 0.01
266
269
  obj.save!
267
- _(obj.reload.real).must_be_close_to 214748.36461, 0.01
270
+ _(obj.reload.real).must_be_close_to 214748.36461, 0.01
268
271
  end
269
272
 
270
273
  # Date and Time
271
274
 
272
- it 'date' do
273
- col = column('date')
274
- _(col.sql_type).must_equal 'date'
275
+ it "date" do
276
+ col = column("date")
277
+ _(col.sql_type).must_equal "date"
275
278
  _(col.type).must_equal :date
276
279
  _(col.null).must_equal true
277
- _(col.default).must_equal connection_dblib_73? ? Date.civil(0001, 1, 1) : '0001-01-01'
280
+ _(col.default).must_equal connection_dblib_73? ? Date.civil(0001, 1, 1) : "0001-01-01"
278
281
  _(obj.date).must_equal Date.civil(0001, 1, 1)
279
282
  _(col.default_function).must_be_nil
280
283
  type = connection.lookup_cast_type_from_column(col)
281
- _(type).must_be_instance_of Type::Date
284
+ _(type).must_be_instance_of Type::Date
282
285
  _(type.limit).must_be_nil
283
286
  _(type.precision).must_be_nil
284
287
  _(type.scale).must_be_nil
285
288
  # Can cast strings. SQL Server format.
286
- obj.date = '04-01-0001'
287
- _(obj.date).must_equal Date.civil(0001, 4, 1)
289
+ obj.date = "04-01-0001"
290
+ _(obj.date).must_equal Date.civil(0001, 4, 1)
288
291
  obj.save!
289
- _(obj.date).must_equal Date.civil(0001, 4, 1)
292
+ _(obj.date).must_equal Date.civil(0001, 4, 1)
290
293
  obj.reload
291
- _(obj.date).must_equal Date.civil(0001, 4, 1)
294
+ _(obj.date).must_equal Date.civil(0001, 4, 1)
292
295
  # Can cast strings. ISO format.
293
- obj.date = '0001-04-01'
294
- _(obj.date).must_equal Date.civil(0001, 4, 1)
296
+ obj.date = "0001-04-01"
297
+ _(obj.date).must_equal Date.civil(0001, 4, 1)
295
298
  obj.save!
296
- _(obj.date).must_equal Date.civil(0001, 4, 1)
299
+ _(obj.date).must_equal Date.civil(0001, 4, 1)
297
300
  obj.reload
298
- _(obj.date).must_equal Date.civil(0001, 4, 1)
301
+ _(obj.date).must_equal Date.civil(0001, 4, 1)
299
302
  # Can keep and return assigned date.
300
303
  assert_obj_set_and_save :date, Date.civil(1972, 04, 14)
301
304
  # Can accept and cast time objects.
302
305
  obj.date = Time.utc(2010, 4, 14, 12, 34, 56, 3000)
303
306
  _(obj.date).must_equal Date.civil(2010, 4, 14)
304
307
  obj.save!
305
- _(obj.reload.date).must_equal Date.civil(2010, 4, 14)
308
+ _(obj.reload.date).must_equal Date.civil(2010, 4, 14)
306
309
  end
307
310
 
308
- it 'datetime' do
309
- col = column('datetime')
310
- _(col.sql_type).must_equal 'datetime'
311
+ it "datetime" do
312
+ col = column("datetime")
313
+ _(col.sql_type).must_equal "datetime"
311
314
  _(col.type).must_equal :datetime
312
315
  _(col.null).must_equal true
313
316
  time = Time.utc 1753, 01, 01, 00, 00, 00, 123000
@@ -315,7 +318,7 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
315
318
  _(obj.datetime).must_equal time, "Microseconds were <#{obj.datetime.usec}> vs <123000>"
316
319
  _(col.default_function).must_be_nil
317
320
  type = connection.lookup_cast_type_from_column(col)
318
- _(type).must_be_instance_of Type::DateTime
321
+ _(type).must_be_instance_of Type::DateTime
319
322
  _(type.limit).must_be_nil
320
323
  _(type.precision).must_be_nil
321
324
  _(type.scale).must_be_nil
@@ -324,21 +327,21 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
324
327
  # Can save to proper accuracy and return again.
325
328
  time = Time.utc 2010, 04, 01, 12, 34, 56, 3000
326
329
  obj.datetime = time
327
- _(obj.datetime).must_equal time, "Microseconds were <#{obj.datetime.usec}> vs <3000>"
330
+ _(obj.datetime).must_equal time, "Microseconds were <#{obj.datetime.usec}> vs <3000>"
328
331
  obj.save!
329
- _(obj.datetime).must_equal time, "Microseconds were <#{obj.datetime.usec}> vs <3000>"
332
+ _(obj.datetime).must_equal time, "Microseconds were <#{obj.datetime.usec}> vs <3000>"
330
333
  obj.reload
331
- _(obj.datetime).must_equal time, "Microseconds were <#{obj.datetime.usec}> vs <3000>"
334
+ _(obj.datetime).must_equal time, "Microseconds were <#{obj.datetime.usec}> vs <3000>"
332
335
  _(obj).must_equal obj.class.where(datetime: time).first
333
336
  # Will cast to true DB value on attribute write, save and return again.
334
- time = Time.utc 2010, 04, 01, 12, 34, 56, 234567
337
+ time = Time.utc 2010, 04, 01, 12, 34, 56, 234567
335
338
  time2 = Time.utc 2010, 04, 01, 12, 34, 56, 233000
336
339
  obj.datetime = time
337
- _(obj.datetime).must_equal time2, "Microseconds were <#{obj.datetime.usec}> vs <233000>"
340
+ _(obj.datetime).must_equal time2, "Microseconds were <#{obj.datetime.usec}> vs <233000>"
338
341
  obj.save!
339
- _(obj.datetime).must_equal time2, "Microseconds were <#{obj.datetime.usec}> vs <233000>"
342
+ _(obj.datetime).must_equal time2, "Microseconds were <#{obj.datetime.usec}> vs <233000>"
340
343
  obj.reload
341
- _(obj.datetime).must_equal time2, "Microseconds were <#{obj.datetime.usec}> vs <233000>"
344
+ _(obj.datetime).must_equal time2, "Microseconds were <#{obj.datetime.usec}> vs <233000>"
342
345
  _(obj).must_equal obj.class.where(datetime: time).first
343
346
  _(obj).must_equal obj.class.where(datetime: time2).first
344
347
  # Set and find nil.
@@ -349,10 +352,10 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
349
352
  _(obj).must_equal obj.class.where(datetime: nil).first
350
353
  end
351
354
 
352
- it 'datetime2' do
353
- skip 'datetime2 not supported in this protocol version' unless connection_dblib_73?
354
- col = column('datetime2_7')
355
- _(col.sql_type).must_equal 'datetime2(7)'
355
+ it "datetime2" do
356
+ skip "datetime2 not supported in this protocol version" unless connection_dblib_73?
357
+ col = column("datetime2_7")
358
+ _(col.sql_type).must_equal "datetime2(7)"
356
359
  _(col.type).must_equal :datetime
357
360
  _(col.null).must_equal true
358
361
  time = Time.utc 9999, 12, 31, 23, 59, 59, Rational(999999900, 1000)
@@ -360,97 +363,97 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
360
363
  _(obj.datetime2_7).must_equal time, "Nanoseconds were <#{obj.datetime2_7.nsec}> vs <999999900>"
361
364
  _(col.default_function).must_be_nil
362
365
  type = connection.lookup_cast_type_from_column(col)
363
- _(type).must_be_instance_of Type::DateTime2
366
+ _(type).must_be_instance_of Type::DateTime2
364
367
  _(type.limit).must_be_nil
365
- _(type.precision).must_equal 7
368
+ _(type.precision).must_equal 7
366
369
  _(type.scale).must_be_nil
367
370
  obj.save!
368
371
  _(obj).must_equal obj.class.where(datetime2_7: time).first
369
372
  # Can save 100 nanosecond precisoins and return again.
370
- time = Time.utc 9999, 12, 31, 23, 59, 59, Rational(123456755, 1000)
373
+ time = Time.utc 9999, 12, 31, 23, 59, 59, Rational(123456755, 1000)
371
374
  time2 = Time.utc 9999, 12, 31, 23, 59, 59, Rational(123456800, 1000)
372
375
  obj.datetime2_7 = time
373
- _(obj.datetime2_7).must_equal time2, "Nanoseconds were <#{obj.datetime2_7.nsec}> vs <123456800>"
376
+ _(obj.datetime2_7).must_equal time2, "Nanoseconds were <#{obj.datetime2_7.nsec}> vs <123456800>"
374
377
  obj.save!
375
- _(obj.datetime2_7).must_equal time2, "Nanoseconds were <#{obj.datetime2_7.nsec}> vs <123456800>"
378
+ _(obj.datetime2_7).must_equal time2, "Nanoseconds were <#{obj.datetime2_7.nsec}> vs <123456800>"
376
379
  obj.reload
377
- _(obj.datetime2_7).must_equal time2, "Nanoseconds were <#{obj.datetime2_7.nsec}> vs <123456800>"
380
+ _(obj.datetime2_7).must_equal time2, "Nanoseconds were <#{obj.datetime2_7.nsec}> vs <123456800>"
378
381
  _(obj).must_equal obj.class.where(datetime2_7: time).first
379
382
  _(obj).must_equal obj.class.where(datetime2_7: time2).first
380
383
  # Can save small fraction nanosecond precisoins and return again.
381
- time = Time.utc 2008, 6, 21, 13, 30, 0, Rational(15020, 1000)
384
+ time = Time.utc 2008, 6, 21, 13, 30, 0, Rational(15020, 1000)
382
385
  time2 = Time.utc 2008, 6, 21, 13, 30, 0, Rational(15000, 1000)
383
386
  obj.datetime2_7 = time
384
- _(obj.datetime2_7).must_equal time2, "Nanoseconds were <#{obj.datetime2_7.nsec}> vs <15000>"
387
+ _(obj.datetime2_7).must_equal time2, "Nanoseconds were <#{obj.datetime2_7.nsec}> vs <15000>"
385
388
  obj.save!
386
- _(obj.reload.datetime2_7).must_equal time2, "Nanoseconds were <#{obj.datetime2_7.nsec}> vs <15000>"
389
+ _(obj.reload.datetime2_7).must_equal time2, "Nanoseconds were <#{obj.datetime2_7.nsec}> vs <15000>"
387
390
  _(obj).must_equal obj.class.where(datetime2_7: time).first
388
391
  _(obj).must_equal obj.class.where(datetime2_7: time2).first
389
392
  # datetime2_3
390
393
  time = Time.utc 9999, 12, 31, 23, 59, 59, Rational(123456789, 1000)
391
- col = column('datetime2_3')
394
+ col = column("datetime2_3")
392
395
  _(connection.lookup_cast_type_from_column(col).precision).must_equal 3
393
396
  obj.datetime2_3 = time
394
397
  _(obj.datetime2_3).must_equal time.change(nsec: 123000000), "Nanoseconds were <#{obj.datetime2_3.nsec}> vs <123000000>"
395
- obj.save! ; obj.reload
398
+ obj.save!; obj.reload
396
399
  _(obj.datetime2_3).must_equal time.change(nsec: 123000000), "Nanoseconds were <#{obj.datetime2_3.nsec}> vs <123000000>"
397
400
  _(obj).must_equal obj.class.where(datetime2_3: time).first
398
401
  # datetime2_1
399
- col = column('datetime2_1')
402
+ col = column("datetime2_1")
400
403
  _(connection.lookup_cast_type_from_column(col).precision).must_equal 1
401
404
  obj.datetime2_1 = time
402
405
  _(obj.datetime2_1).must_equal time.change(nsec: 100000000), "Nanoseconds were <#{obj.datetime2_1.nsec}> vs <100000000>"
403
- obj.save! ; obj.reload
406
+ obj.save!; obj.reload
404
407
  _(obj.datetime2_1).must_equal time.change(nsec: 100000000), "Nanoseconds were <#{obj.datetime2_1.nsec}> vs <100000000>"
405
408
  _(obj).must_equal obj.class.where(datetime2_1: time).first
406
409
  # datetime2_0
407
- col = column('datetime2_0')
410
+ col = column("datetime2_0")
408
411
  _(connection.lookup_cast_type_from_column(col).precision).must_equal 0
409
412
  time = Time.utc 2016, 4, 19, 16, 45, 40, 771036
410
413
  obj.datetime2_0 = time
411
414
  _(obj.datetime2_0).must_equal time.change(nsec: 0), "Nanoseconds were <#{obj.datetime2_0.nsec}> vs <0>"
412
- obj.save! ; obj.reload
415
+ obj.save!; obj.reload
413
416
  _(obj.datetime2_0).must_equal time.change(nsec: 0), "Nanoseconds were <#{obj.datetime2_0.nsec}> vs <0>"
414
417
  _(obj).must_equal obj.class.where(datetime2_0: time).first
415
418
  end
416
419
 
417
- it 'datetimeoffset' do
418
- skip 'datetimeoffset not supported in this protocol version' unless connection_dblib_73?
419
- col = column('datetimeoffset_7')
420
- _(col.sql_type).must_equal 'datetimeoffset(7)'
420
+ it "datetimeoffset" do
421
+ skip "datetimeoffset not supported in this protocol version" unless connection_dblib_73?
422
+ col = column("datetimeoffset_7")
423
+ _(col.sql_type).must_equal "datetimeoffset(7)"
421
424
  _(col.type).must_equal :datetimeoffset
422
425
  _(col.null).must_equal true
423
426
  _(col.default).must_equal Time.new(1984, 01, 24, 04, 20, 00, -28800).change(nsec: 123456700), "Nanoseconds <#{col.default.nsec}> vs <123456700>"
424
427
  _(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>"
425
428
  _(col.default_function).must_be_nil
426
429
  type = connection.lookup_cast_type_from_column(col)
427
- _(type).must_be_instance_of Type::DateTimeOffset
430
+ _(type).must_be_instance_of Type::DateTimeOffset
428
431
  _(type.limit).must_be_nil
429
- _(type.precision).must_equal 7
432
+ _(type.precision).must_equal 7
430
433
  _(type.scale).must_be_nil
431
434
  # Can save 100 nanosecond precisoins and return again.
432
435
  obj.datetimeoffset_7 = Time.new(2010, 04, 01, 12, 34, 56, +18000).change(nsec: 123456755)
433
- _(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>"
434
437
  obj.save!
435
- _(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>"
438
+ _(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
439
  obj.reload
437
- _(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>"
440
+ _(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>"
438
441
  # Maintains the timezone
439
- time = ActiveSupport::TimeZone['America/Los_Angeles'].local 2010, 12, 31, 23, 59, 59, Rational(123456800, 1000)
442
+ time = ActiveSupport::TimeZone["America/Los_Angeles"].local 2010, 12, 31, 23, 59, 59, Rational(123456800, 1000)
440
443
  obj.datetimeoffset_7 = time
441
444
  _(obj.datetimeoffset_7).must_equal time
442
445
  obj.save!
443
446
  _(obj.datetimeoffset_7).must_equal time
444
447
  _(obj.reload.datetimeoffset_7).must_equal time
445
448
  # With other precisions.
446
- time = ActiveSupport::TimeZone['America/Los_Angeles'].local 2010, 12, 31, 23, 59, 59, Rational(123456755, 1000)
447
- col = column('datetimeoffset_3')
449
+ time = ActiveSupport::TimeZone["America/Los_Angeles"].local 2010, 12, 31, 23, 59, 59, Rational(123456755, 1000)
450
+ col = column("datetimeoffset_3")
448
451
  _(connection.lookup_cast_type_from_column(col).precision).must_equal 3
449
452
  obj.datetimeoffset_3 = time
450
453
  _(obj.datetimeoffset_3).must_equal time.change(nsec: 123000000), "Nanoseconds were <#{obj.datetimeoffset_3.nsec}> vs <123000000>"
451
454
  obj.save!
452
455
  _(obj.datetimeoffset_3).must_equal time.change(nsec: 123000000), "Nanoseconds were <#{obj.datetimeoffset_3.nsec}> vs <123000000>"
453
- col = column('datetime2_1')
456
+ col = column("datetime2_1")
454
457
  _(connection.lookup_cast_type_from_column(col).precision).must_equal 1
455
458
  obj.datetime2_1 = time
456
459
  _(obj.datetime2_1).must_equal time.change(nsec: 100000000), "Nanoseconds were <#{obj.datetime2_1.nsec}> vs <100000000>"
@@ -458,131 +461,131 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
458
461
  _(obj.datetime2_1).must_equal time.change(nsec: 100000000), "Nanoseconds were <#{obj.datetime2_1.nsec}> vs <100000000>"
459
462
  end
460
463
 
461
- it 'smalldatetime' do
462
- col = column('smalldatetime')
463
- _(col.sql_type).must_equal 'smalldatetime'
464
+ it "smalldatetime" do
465
+ col = column("smalldatetime")
466
+ _(col.sql_type).must_equal "smalldatetime"
464
467
  _(col.type).must_equal :smalldatetime
465
468
  _(col.null).must_equal true
466
469
  _(col.default).must_equal Time.utc(1901, 01, 01, 15, 45, 00, 000)
467
470
  _(obj.smalldatetime).must_equal Time.utc(1901, 01, 01, 15, 45, 00, 000)
468
471
  _(col.default_function).must_be_nil
469
472
  type = connection.lookup_cast_type_from_column(col)
470
- _(type).must_be_instance_of Type::SmallDateTime
473
+ _(type).must_be_instance_of Type::SmallDateTime
471
474
  _(type.limit).must_be_nil
472
475
  _(type.precision).must_be_nil
473
476
  _(type.scale).must_be_nil
474
477
  # Will remove fractional seconds and return again.
475
478
  obj.smalldatetime = Time.utc(2078, 06, 05, 4, 20, 00, 3000)
476
- _(obj.smalldatetime).must_equal Time.utc(2078, 06, 05, 4, 20, 00, 0), "Microseconds were <#{obj.smalldatetime.usec}> vs <0>"
479
+ _(obj.smalldatetime).must_equal Time.utc(2078, 06, 05, 4, 20, 00, 0), "Microseconds were <#{obj.smalldatetime.usec}> vs <0>"
477
480
  obj.save!
478
- _(obj.smalldatetime).must_equal Time.utc(2078, 06, 05, 4, 20, 00, 0), "Microseconds were <#{obj.reload.smalldatetime.usec}> vs <0>"
481
+ _(obj.smalldatetime).must_equal Time.utc(2078, 06, 05, 4, 20, 00, 0), "Microseconds were <#{obj.reload.smalldatetime.usec}> vs <0>"
479
482
  obj.reload
480
- _(obj.smalldatetime).must_equal Time.utc(2078, 06, 05, 4, 20, 00, 0), "Microseconds were <#{obj.reload.smalldatetime.usec}> vs <0>"
483
+ _(obj.smalldatetime).must_equal Time.utc(2078, 06, 05, 4, 20, 00, 0), "Microseconds were <#{obj.reload.smalldatetime.usec}> vs <0>"
481
484
  end
482
485
 
483
- it 'time(7)' do
484
- skip 'time() not supported in this protocol version' unless connection_dblib_73?
485
- col = column('time_7')
486
- _(col.sql_type).must_equal 'time(7)'
486
+ it "time(7)" do
487
+ skip "time() not supported in this protocol version" unless connection_dblib_73?
488
+ col = column("time_7")
489
+ _(col.sql_type).must_equal "time(7)"
487
490
  _(col.type).must_equal :time
488
491
  _(col.null).must_equal true
489
492
  _(col.default).must_equal Time.utc(1900, 01, 01, 04, 20, 00, Rational(288321500, 1000)), "Nanoseconds were <#{col.default.nsec}> vs <288321500>"
490
493
  _(col.default_function).must_be_nil
491
494
  type = connection.lookup_cast_type_from_column(col)
492
- _(type).must_be_instance_of Type::Time
495
+ _(type).must_be_instance_of Type::Time
493
496
  _(type.limit).must_be_nil
494
- _(type.precision).must_equal 7
497
+ _(type.precision).must_equal 7
495
498
  _(type.scale).must_be_nil
496
499
  # Time's #usec precision (low micro)
497
500
  obj.time_7 = Time.utc(2000, 01, 01, 15, 45, 00, 300)
498
501
  _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Microseconds were <#{obj.time_7.usec}> vs <0>"
499
502
  _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Nanoseconds were <#{obj.time_7.nsec}> vs <300>"
500
- obj.save! ; obj.reload
503
+ obj.save!; obj.reload
501
504
  _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Microseconds were <#{obj.time_7.usec}> vs <0>"
502
505
  _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Nanoseconds were <#{obj.time_7.nsec}> vs <300>"
503
506
  # Time's #usec precision (high micro)
504
507
  obj.time_7 = Time.utc(2000, 01, 01, 15, 45, 00, 234567)
505
- _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 234567), "Microseconds were <#{obj.time_7.usec}> vs <234567>"
506
- obj.save! ; obj.reload
507
- _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 234567), "Microseconds were <#{obj.time_7.usec}> vs <234567>"
508
+ _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 234567), "Microseconds were <#{obj.time_7.usec}> vs <234567>"
509
+ obj.save!; obj.reload
510
+ _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 234567), "Microseconds were <#{obj.time_7.usec}> vs <234567>"
508
511
  # Time's #usec precision (high nano rounded)
509
512
  obj.time_7 = Time.utc(2000, 01, 01, 15, 45, 00, Rational(288321545, 1000))
510
- _(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.save! ; obj.reload
512
- _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, Rational(288321500, 1000)), "Nanoseconds were <#{obj.time_7.nsec}> vs <288321500>"
513
+ _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, Rational(288321500, 1000)), "Nanoseconds were <#{obj.time_7.nsec}> vs <288321500>"
514
+ obj.save!; obj.reload
515
+ _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, Rational(288321500, 1000)), "Nanoseconds were <#{obj.time_7.nsec}> vs <288321500>"
513
516
  end
514
517
 
515
- it 'time(2)' do
516
- skip 'time() not supported in this protocol version' unless connection_dblib_73?
517
- col = column('time_2')
518
- _(col.sql_type).must_equal 'time(2)'
518
+ it "time(2)" do
519
+ skip "time() not supported in this protocol version" unless connection_dblib_73?
520
+ col = column("time_2")
521
+ _(col.sql_type).must_equal "time(2)"
519
522
  _(col.type).must_equal :time
520
523
  _(col.null).must_equal true
521
524
  _(col.default).must_be_nil
522
525
  _(col.default_function).must_be_nil
523
526
  type = connection.lookup_cast_type_from_column(col)
524
- _(type).must_be_instance_of Type::Time
527
+ _(type).must_be_instance_of Type::Time
525
528
  _(type.limit).must_be_nil
526
- _(type.precision).must_equal 2
529
+ _(type.precision).must_equal 2
527
530
  _(type.scale).must_be_nil
528
531
  # Always uses TinyTDS/Windows 2000-01-01 convention too.
529
532
  obj.time_2 = Time.utc(2015, 01, 10, 15, 45, 00, 0)
530
- _(obj.time_2).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 0)
531
- obj.save! ; obj.reload
532
- _(obj.time_2).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 0)
533
+ _(obj.time_2).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 0)
534
+ obj.save!; obj.reload
535
+ _(obj.time_2).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 0)
533
536
  # Time's #usec precision (barely in 2 precision equal to 0.03 seconds)
534
537
  obj.time_2 = Time.utc(2000, 01, 01, 15, 45, 00, 30000)
535
- _(obj.time_2).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 30000), "Microseconds were <#{obj.time_2.usec}> vs <30000>"
536
- obj.save! ; obj.reload
537
- _(obj.time_2).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 30000), "Microseconds were <#{obj.time_2.usec}> vs <30000>"
538
+ _(obj.time_2).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 30000), "Microseconds were <#{obj.time_2.usec}> vs <30000>"
539
+ obj.save!; obj.reload
540
+ _(obj.time_2).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 30000), "Microseconds were <#{obj.time_2.usec}> vs <30000>"
538
541
  # Time's #usec precision (below 2 precision)
539
542
  obj.time_2 = Time.utc(2000, 01, 01, 15, 45, 00, 4000)
540
- _(obj.time_2).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 0), "Microseconds were <#{obj.time_2.usec}> vs <0>"
541
- obj.save! ; obj.reload
542
- _(obj.time_2).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 0), "Microseconds were <#{obj.time_2.usec}> vs <0>"
543
+ _(obj.time_2).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 0), "Microseconds were <#{obj.time_2.usec}> vs <0>"
544
+ obj.save!; obj.reload
545
+ _(obj.time_2).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 0), "Microseconds were <#{obj.time_2.usec}> vs <0>"
543
546
  end
544
547
 
545
- it 'time using default precision' do
546
- skip 'time() not supported in this protocol version' unless connection_dblib_73?
547
- col = column('time_default')
548
- _(col.sql_type).must_equal 'time(7)'
548
+ it "time using default precision" do
549
+ skip "time() not supported in this protocol version" unless connection_dblib_73?
550
+ col = column("time_default")
551
+ _(col.sql_type).must_equal "time(7)"
549
552
  _(col.type).must_equal :time
550
553
  _(col.null).must_equal true
551
554
  _(col.default).must_equal Time.utc(1900, 01, 01, 15, 03, 42, Rational(62197800, 1000)), "Nanoseconds were <#{col.default.nsec}> vs <62197800>"
552
555
  _(col.default_function).must_be_nil
553
556
  type = connection.lookup_cast_type_from_column(col)
554
- _(type).must_be_instance_of Type::Time
557
+ _(type).must_be_instance_of Type::Time
555
558
  _(type.limit).must_be_nil
556
- _(type.precision).must_equal 7
559
+ _(type.precision).must_equal 7
557
560
  _(type.scale).must_be_nil
558
561
  # Time's #usec precision (low micro)
559
562
  obj.time_default = Time.utc(2000, 01, 01, 15, 45, 00, 300)
560
563
  _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Microseconds were <#{obj.time_default.usec}> vs <0>"
561
564
  _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Nanoseconds were <#{obj.time_default.nsec}> vs <300>"
562
- obj.save! ; obj.reload
565
+ obj.save!; obj.reload
563
566
  _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Microseconds were <#{obj.time_default.usec}> vs <0>"
564
567
  _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Nanoseconds were <#{obj.time_default.nsec}> vs <300>"
565
568
  # Time's #usec precision (high micro)
566
569
  obj.time_default = Time.utc(2000, 01, 01, 15, 45, 00, 234567)
567
- _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 234567), "Microseconds were <#{obj.time_default.usec}> vs <234567>"
568
- obj.save! ; obj.reload
569
- _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 234567), "Microseconds were <#{obj.time_default.usec}> vs <234567>"
570
+ _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 234567), "Microseconds were <#{obj.time_default.usec}> vs <234567>"
571
+ obj.save!; obj.reload
572
+ _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 234567), "Microseconds were <#{obj.time_default.usec}> vs <234567>"
570
573
  # Time's #usec precision (high nano rounded)
571
574
  obj.time_default = Time.utc(2000, 01, 01, 15, 45, 00, Rational(288321545, 1000))
572
- _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, Rational(288321500, 1000)), "Nanoseconds were <#{obj.time_default.nsec}> vs <288321500>"
573
- obj.save! ; obj.reload
574
- _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, Rational(288321500, 1000)), "Nanoseconds were <#{obj.time_default.nsec}> vs <288321500>"
575
+ _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, Rational(288321500, 1000)), "Nanoseconds were <#{obj.time_default.nsec}> vs <288321500>"
576
+ obj.save!; obj.reload
577
+ _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, Rational(288321500, 1000)), "Nanoseconds were <#{obj.time_default.nsec}> vs <288321500>"
575
578
  end
576
579
 
577
580
  # Character Strings
578
581
 
579
- it 'char(10)' do
580
- col = column('char_10')
581
- _(col.sql_type).must_equal 'char(10)'
582
+ it "char(10)" do
583
+ col = column("char_10")
584
+ _(col.sql_type).must_equal "char(10)"
582
585
  _(col.type).must_equal :char
583
586
  _(col.null).must_equal true
584
- _(col.default).must_equal '1234567890'
585
- _(obj.char_10).must_equal '1234567890'
587
+ _(col.default).must_equal "1234567890"
588
+ _(obj.char_10).must_equal "1234567890"
586
589
  _(col.default_function).must_be_nil
587
590
  type = connection.lookup_cast_type_from_column(col)
588
591
  _(type).must_be_instance_of Type::Char
@@ -590,19 +593,19 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
590
593
  _(type.precision).must_be_nil
591
594
  _(type.scale).must_be_nil
592
595
  # Basic set and save.
593
- obj.char_10 = '012345'
594
- _(obj.char_10.strip).must_equal '012345'
596
+ obj.char_10 = "012345"
597
+ _(obj.char_10.strip).must_equal "012345"
595
598
  obj.save!
596
- _(obj.reload.char_10.strip).must_equal '012345'
599
+ _(obj.reload.char_10.strip).must_equal "012345"
597
600
  end
598
601
 
599
- it 'varchar(50)' do
600
- col = column('varchar_50')
601
- _(col.sql_type).must_equal 'varchar(50)'
602
+ it "varchar(50)" do
603
+ col = column("varchar_50")
604
+ _(col.sql_type).must_equal "varchar(50)"
602
605
  _(col.type).must_equal :varchar
603
606
  _(col.null).must_equal true
604
- _(col.default).must_equal 'test varchar_50'
605
- _(obj.varchar_50).must_equal 'test varchar_50'
607
+ _(col.default).must_equal "test varchar_50"
608
+ _(obj.varchar_50).must_equal "test varchar_50"
606
609
  _(col.default_function).must_be_nil
607
610
  type = connection.lookup_cast_type_from_column(col)
608
611
  _(type).must_be_instance_of Type::Varchar
@@ -610,16 +613,16 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
610
613
  _(type.precision).must_be_nil
611
614
  _(type.scale).must_be_nil
612
615
  # Basic set and save.
613
- assert_obj_set_and_save :varchar_50, 'Hello World'
616
+ assert_obj_set_and_save :varchar_50, "Hello World"
614
617
  end
615
618
 
616
- it 'varchar(max)' do
617
- col = column('varchar_max')
618
- _(col.sql_type).must_equal 'varchar(max)'
619
+ it "varchar(max)" do
620
+ col = column("varchar_max")
621
+ _(col.sql_type).must_equal "varchar(max)"
619
622
  _(col.type).must_equal :varchar_max
620
623
  _(col.null).must_equal true
621
- _(col.default).must_equal 'test varchar_max'
622
- _(obj.varchar_max).must_equal 'test varchar_max'
624
+ _(col.default).must_equal "test varchar_max"
625
+ _(obj.varchar_max).must_equal "test varchar_max"
623
626
  _(col.default_function).must_be_nil
624
627
  type = connection.lookup_cast_type_from_column(col)
625
628
  _(type).must_be_instance_of Type::VarcharMax
@@ -627,16 +630,16 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
627
630
  _(type.precision).must_be_nil
628
631
  _(type.scale).must_be_nil
629
632
  # Basic set and save.
630
- assert_obj_set_and_save :varchar_max, 'Hello World'
633
+ assert_obj_set_and_save :varchar_max, "Hello World"
631
634
  end
632
635
 
633
- it 'text' do
634
- col = column('text')
635
- _(col.sql_type).must_equal 'text'
636
+ it "text" do
637
+ col = column("text")
638
+ _(col.sql_type).must_equal "text"
636
639
  _(col.type).must_equal :text_basic
637
640
  _(col.null).must_equal true
638
- _(col.default).must_equal 'test text'
639
- _(obj.text).must_equal 'test text'
641
+ _(col.default).must_equal "test text"
642
+ _(obj.text).must_equal "test text"
640
643
  _(col.default_function).must_be_nil
641
644
  type = connection.lookup_cast_type_from_column(col)
642
645
  _(type).must_be_instance_of Type::Text
@@ -644,18 +647,18 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
644
647
  _(type.precision).must_be_nil
645
648
  _(type.scale).must_be_nil
646
649
  # Basic set and save.
647
- assert_obj_set_and_save :text, 'Hello World'
650
+ assert_obj_set_and_save :text, "Hello World"
648
651
  end
649
652
 
650
653
  # Unicode Character Strings
651
654
 
652
- it 'nchar(10)' do
653
- col = column('nchar_10')
654
- _(col.sql_type).must_equal 'nchar(10)'
655
+ it "nchar(10)" do
656
+ col = column("nchar_10")
657
+ _(col.sql_type).must_equal "nchar(10)"
655
658
  _(col.type).must_equal :nchar
656
659
  _(col.null).must_equal true
657
- _(col.default).must_equal '12345678åå'
658
- _(obj.nchar_10).must_equal '12345678åå'
660
+ _(col.default).must_equal "12345678åå"
661
+ _(obj.nchar_10).must_equal "12345678åå"
659
662
  _(col.default_function).must_be_nil
660
663
  type = connection.lookup_cast_type_from_column(col)
661
664
  _(type).must_be_instance_of Type::UnicodeChar
@@ -664,18 +667,18 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
664
667
  _(type.scale).must_be_nil
665
668
  # Basic set and save.
666
669
  obj.nchar_10 = "五六"
667
- _(obj.nchar_10.strip).must_equal "五六"
670
+ _(obj.nchar_10.strip).must_equal "五六"
668
671
  obj.save!
669
- _(obj.reload.nchar_10.strip).must_equal "五六"
672
+ _(obj.reload.nchar_10.strip).must_equal "五六"
670
673
  end
671
674
 
672
- it 'nvarchar(50)' do
673
- col = column('nvarchar_50')
674
- _(col.sql_type).must_equal 'nvarchar(50)'
675
+ it "nvarchar(50)" do
676
+ col = column("nvarchar_50")
677
+ _(col.sql_type).must_equal "nvarchar(50)"
675
678
  _(col.type).must_equal :string
676
679
  _(col.null).must_equal true
677
- _(col.default).must_equal 'test nvarchar_50 åå'
678
- _(obj.nvarchar_50).must_equal 'test nvarchar_50 åå'
680
+ _(col.default).must_equal "test nvarchar_50 åå"
681
+ _(obj.nvarchar_50).must_equal "test nvarchar_50 åå"
679
682
  _(col.default_function).must_be_nil
680
683
  type = connection.lookup_cast_type_from_column(col)
681
684
  _(type).must_be_instance_of Type::UnicodeVarchar
@@ -686,13 +689,13 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
686
689
  assert_obj_set_and_save :nvarchar_50, "一二34五六"
687
690
  end
688
691
 
689
- it 'nvarchar(max)' do
690
- col = column('nvarchar_max')
691
- _(col.sql_type).must_equal 'nvarchar(max)'
692
+ it "nvarchar(max)" do
693
+ col = column("nvarchar_max")
694
+ _(col.sql_type).must_equal "nvarchar(max)"
692
695
  _(col.type).must_equal :text
693
696
  _(col.null).must_equal true
694
- _(col.default).must_equal 'test nvarchar_max åå'
695
- _(obj.nvarchar_max).must_equal 'test nvarchar_max åå'
697
+ _(col.default).must_equal "test nvarchar_max åå"
698
+ _(obj.nvarchar_max).must_equal "test nvarchar_max åå"
696
699
  _(col.default_function).must_be_nil
697
700
  type = connection.lookup_cast_type_from_column(col)
698
701
  _(type).must_be_instance_of Type::UnicodeVarcharMax
@@ -703,13 +706,13 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
703
706
  assert_obj_set_and_save :nvarchar_max, "一二34五六"
704
707
  end
705
708
 
706
- it 'ntext' do
707
- col = column('ntext')
708
- _(col.sql_type).must_equal 'ntext'
709
+ it "ntext" do
710
+ col = column("ntext")
711
+ _(col.sql_type).must_equal "ntext"
709
712
  _(col.type).must_equal :ntext
710
713
  _(col.null).must_equal true
711
- _(col.default).must_equal 'test ntext åå'
712
- _(obj.ntext).must_equal 'test ntext åå'
714
+ _(col.default).must_equal "test ntext åå"
715
+ _(obj.ntext).must_equal "test ntext åå"
713
716
  _(col.default_function).must_be_nil
714
717
  type = connection.lookup_cast_type_from_column(col)
715
718
  _(type).must_be_instance_of Type::UnicodeText
@@ -722,12 +725,12 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
722
725
 
723
726
  # Binary Strings
724
727
 
725
- let(:binary_file) { File.join ARTest::SQLServer.test_root_sqlserver, 'fixtures', '1px.gif' }
726
- let(:binary_data) { File.open(binary_file, 'rb') { |f| f.read } }
728
+ let(:binary_file) { File.join ARTest::SQLServer.test_root_sqlserver, "fixtures", "1px.gif" }
729
+ let(:binary_data) { File.open(binary_file, "rb") { |f| f.read } }
727
730
 
728
- it 'binary(49)' do
729
- col = column('binary_49')
730
- _(col.sql_type).must_equal 'binary(49)'
731
+ it "binary(49)" do
732
+ col = column("binary_49")
733
+ _(col.sql_type).must_equal "binary(49)"
731
734
  _(col.type).must_equal :binary_basic
732
735
  _(col.null).must_equal true
733
736
  _(col.default).must_be_nil
@@ -746,9 +749,9 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
746
749
  _(obj.reload.binary_49).must_equal binary_data
747
750
  end
748
751
 
749
- it 'varbinary(49)' do
750
- col = column('varbinary_49')
751
- _(col.sql_type).must_equal 'varbinary(49)'
752
+ it "varbinary(49)" do
753
+ col = column("varbinary_49")
754
+ _(col.sql_type).must_equal "varbinary(49)"
752
755
  _(col.type).must_equal :varbinary
753
756
  _(col.null).must_equal true
754
757
  _(col.default).must_be_nil
@@ -759,17 +762,17 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
759
762
  _(type.precision).must_be_nil
760
763
  _(type.scale).must_be_nil
761
764
  # Basic set and save.
762
- binary_data_20 = binary_data.to(20)
763
- _(binary_data_20.encoding).must_equal Encoding::BINARY
764
- obj.varbinary_49 = binary_data_20
765
- _(obj.varbinary_49).must_equal binary_data_20
765
+ binary_data20 = binary_data.to(20)
766
+ _(binary_data20.encoding).must_equal Encoding::BINARY
767
+ obj.varbinary_49 = binary_data20
768
+ _(obj.varbinary_49).must_equal binary_data20
766
769
  obj.save!
767
- _(obj.reload.varbinary_49).must_equal binary_data_20
770
+ _(obj.reload.varbinary_49).must_equal binary_data20
768
771
  end
769
772
 
770
- it 'varbinary(max)' do
771
- col = column('varbinary_max')
772
- _(col.sql_type).must_equal 'varbinary(max)'
773
+ it "varbinary(max)" do
774
+ col = column("varbinary_max")
775
+ _(col.sql_type).must_equal "varbinary(max)"
773
776
  _(col.type).must_equal :binary
774
777
  _(col.null).must_equal true
775
778
  _(col.default).must_be_nil
@@ -786,57 +789,55 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
786
789
 
787
790
  # Other Data Types
788
791
 
789
- it 'uniqueidentifier' do
790
- col = column('uniqueidentifier')
791
- _(col.sql_type).must_equal 'uniqueidentifier'
792
+ it "uniqueidentifier" do
793
+ col = column("uniqueidentifier")
794
+ _(col.sql_type).must_equal "uniqueidentifier"
792
795
  _(col.type).must_equal :uuid
793
796
  _(col.null).must_equal true
794
797
  _(col.default).must_be_nil
795
- _(col.default_function).must_equal 'newid()'
798
+ _(col.default_function).must_equal "newid()"
796
799
  type = connection.lookup_cast_type_from_column(col)
797
- _(type).must_be_instance_of Type::Uuid
800
+ _(type).must_be_instance_of Type::Uuid
798
801
  _(type.limit).must_be_nil
799
802
  _(type.precision).must_be_nil
800
803
  _(type.scale).must_be_nil
801
804
  # Basic set and save.
802
805
  obj.uniqueidentifier = "this will not qualify as valid"
803
806
  _(obj.uniqueidentifier).must_be_nil
804
- obj.save! ; obj.reload
805
- _(obj.uniqueidentifier).must_match Type::Uuid::ACCEPTABLE_UUID
807
+ obj.save!; obj.reload
808
+ _(obj.uniqueidentifier).must_match Type::Uuid::ACCEPTABLE_UUID
806
809
  obj.uniqueidentifier = "6F9619FF-8B86-D011-B42D-00C04FC964FF"
807
- _(obj.uniqueidentifier).must_equal "6F9619FF-8B86-D011-B42D-00C04FC964FF"
808
- obj.save! ; obj.reload
809
- _(obj.uniqueidentifier).must_equal "6F9619FF-8B86-D011-B42D-00C04FC964FF"
810
+ _(obj.uniqueidentifier).must_equal "6F9619FF-8B86-D011-B42D-00C04FC964FF"
811
+ obj.save!; obj.reload
812
+ _(obj.uniqueidentifier).must_equal "6F9619FF-8B86-D011-B42D-00C04FC964FF"
810
813
  end
811
814
 
812
- it 'timestamp' do
813
- col = column('timestamp')
814
- _(col.sql_type).must_equal 'timestamp'
815
+ it "timestamp" do
816
+ col = column("timestamp")
817
+ _(col.sql_type).must_equal "timestamp"
815
818
  _(col.type).must_equal :ss_timestamp
816
819
  _(col.null).must_equal true
817
820
  _(col.default).must_be_nil
818
821
  _(col.default_function).must_be_nil
819
822
  type = connection.lookup_cast_type_from_column(col)
820
- _(type).must_be_instance_of Type::Timestamp
823
+ _(type).must_be_instance_of Type::Timestamp
821
824
  _(type.limit).must_be_nil
822
825
  _(type.precision).must_be_nil
823
826
  _(type.scale).must_be_nil
824
827
  # Basic read.
825
828
  _(obj.timestamp).must_be_nil
826
- obj.save! ; obj.reload
827
- _(obj.timestamp).must_match %r|\000|
829
+ obj.save!; obj.reload
830
+ _(obj.timestamp).must_match %r|\000|
828
831
  obj.timestamp
829
832
  # Can set another attribute
830
833
  obj.uniqueidentifier = "6F9619FF-8B86-D011-B42D-00C04FC964FF"
831
834
  obj.save!
832
835
  end
833
836
 
834
- it 'does not mark object as changed after save' do
837
+ it "does not mark object as changed after save" do
835
838
  obj.save!
836
839
  obj.attributes
837
840
  _(obj.changed?).must_equal false
838
841
  end
839
-
840
842
  end
841
-
842
843
  end