Skip to content

Commit 7ebd5f6

Browse files
committed
Clean up more code related with rails#52817
1 parent 62da6e2 commit 7ebd5f6

File tree

3 files changed

+31
-44
lines changed

3 files changed

+31
-44
lines changed

activerecord/lib/active_record/connection_adapters/mysql/quoting.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,6 @@ def unquoted_false
7777
0
7878
end
7979

80-
def quoted_date(value)
81-
if supports_datetime_with_precision?
82-
super
83-
else
84-
super.sub(/\.\d{6}\z/, "")
85-
end
86-
end
87-
8880
def quoted_binary(value)
8981
"x'#{value.hex}'"
9082
end

activerecord/test/cases/base_test.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,10 @@ def test_preserving_time_objects
258258
"The written_on attribute should be of the Time class"
259259
)
260260

261-
# For adapters which support microsecond resolution.
262-
if supports_datetime_with_precision?
263-
assert_equal 11, Topic.find(1).written_on.sec
264-
assert_equal 223300, Topic.find(1).written_on.usec
265-
assert_equal 9900, Topic.find(2).written_on.usec
266-
assert_equal 129346, Topic.find(3).written_on.usec
267-
end
261+
assert_equal 11, Topic.find(1).written_on.sec
262+
assert_equal 223300, Topic.find(1).written_on.usec
263+
assert_equal 9900, Topic.find(2).written_on.usec
264+
assert_equal 129346, Topic.find(3).written_on.usec
268265
end
269266

270267
def test_preserving_time_objects_with_local_time_conversion_to_default_timezone_utc

activerecord/test/cases/defaults_test.rb

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -182,41 +182,39 @@ class MysqlDefaultExpressionTest < ActiveRecord::TestCase
182182
end
183183
end
184184

185-
if supports_datetime_with_precision?
186-
test "schema dump datetime includes default expression" do
187-
output = dump_table_schema("datetime_defaults")
188-
assert_match %r/t\.datetime\s+"modified_datetime",\s+precision: nil,\s+default: -> { "CURRENT_TIMESTAMP(?:\(\))?" }/i, output
189-
end
185+
test "schema dump datetime includes default expression" do
186+
output = dump_table_schema("datetime_defaults")
187+
assert_match %r/t\.datetime\s+"modified_datetime",\s+precision: nil,\s+default: -> { "CURRENT_TIMESTAMP(?:\(\))?" }/i, output
188+
end
190189

191-
test "schema dump datetime includes precise default expression" do
192-
output = dump_table_schema("datetime_defaults")
193-
assert_match %r/t\.datetime\s+"precise_datetime",\s+default: -> { "CURRENT_TIMESTAMP\(6\)" }/i, output
194-
end
190+
test "schema dump datetime includes precise default expression" do
191+
output = dump_table_schema("datetime_defaults")
192+
assert_match %r/t\.datetime\s+"precise_datetime",\s+default: -> { "CURRENT_TIMESTAMP\(6\)" }/i, output
193+
end
195194

196-
test "schema dump datetime includes precise default expression with on update" do
197-
output = dump_table_schema("datetime_defaults")
198-
assert_match %r/t\.datetime\s+"updated_datetime",\s+default: -> { "CURRENT_TIMESTAMP\(6\) ON UPDATE CURRENT_TIMESTAMP\(6\)" }/i, output
199-
end
195+
test "schema dump datetime includes precise default expression with on update" do
196+
output = dump_table_schema("datetime_defaults")
197+
assert_match %r/t\.datetime\s+"updated_datetime",\s+default: -> { "CURRENT_TIMESTAMP\(6\) ON UPDATE CURRENT_TIMESTAMP\(6\)" }/i, output
198+
end
200199

201-
test "schema dump timestamp includes default expression" do
202-
output = dump_table_schema("timestamp_defaults")
203-
assert_match %r/t\.timestamp\s+"modified_timestamp",\s+default: -> { "CURRENT_TIMESTAMP(?:\(\))?" }/i, output
204-
end
200+
test "schema dump timestamp includes default expression" do
201+
output = dump_table_schema("timestamp_defaults")
202+
assert_match %r/t\.timestamp\s+"modified_timestamp",\s+default: -> { "CURRENT_TIMESTAMP(?:\(\))?" }/i, output
203+
end
205204

206-
test "schema dump timestamp includes precise default expression" do
207-
output = dump_table_schema("timestamp_defaults")
208-
assert_match %r/t\.timestamp\s+"precise_timestamp",.+default: -> { "CURRENT_TIMESTAMP\(6\)" }/i, output
209-
end
205+
test "schema dump timestamp includes precise default expression" do
206+
output = dump_table_schema("timestamp_defaults")
207+
assert_match %r/t\.timestamp\s+"precise_timestamp",.+default: -> { "CURRENT_TIMESTAMP\(6\)" }/i, output
208+
end
210209

211-
test "schema dump timestamp includes precise default expression with on update" do
212-
output = dump_table_schema("timestamp_defaults")
213-
assert_match %r/t\.timestamp\s+"updated_timestamp",.+default: -> { "CURRENT_TIMESTAMP\(6\) ON UPDATE CURRENT_TIMESTAMP\(6\)" }/i, output
214-
end
210+
test "schema dump timestamp includes precise default expression with on update" do
211+
output = dump_table_schema("timestamp_defaults")
212+
assert_match %r/t\.timestamp\s+"updated_timestamp",.+default: -> { "CURRENT_TIMESTAMP\(6\) ON UPDATE CURRENT_TIMESTAMP\(6\)" }/i, output
213+
end
215214

216-
test "schema dump timestamp without default expression" do
217-
output = dump_table_schema("timestamp_defaults")
218-
assert_match %r/t\.timestamp\s+"nullable_timestamp"$/, output
219-
end
215+
test "schema dump timestamp without default expression" do
216+
output = dump_table_schema("timestamp_defaults")
217+
assert_match %r/t\.timestamp\s+"nullable_timestamp"$/, output
220218
end
221219
end
222220
end

0 commit comments

Comments
 (0)