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