Skip to content

Commit 96f9771

Browse files
BuonOmorafiss
authored andcommitted
fix: remove likely deadcode
1 parent 9e2facb commit 96f9771

File tree

1 file changed

+0
-27
lines changed

1 file changed

+0
-27
lines changed

lib/active_record/connection_adapters/cockroachdb_adapter.rb

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ def initialize_type_map(m = type_map)
328328
def extract_value_from_default(default)
329329
super ||
330330
extract_escaped_string_from_default(default) ||
331-
extract_time_from_default(default) ||
332331
extract_empty_array_from_default(default) ||
333332
extract_decimal_from_default(default)
334333
end
@@ -346,32 +345,6 @@ def extract_escaped_string_from_default(default)
346345
"\"#{$1}\"".undump.gsub("\\'".freeze, "'".freeze)
347346
end
348347

349-
# This method exists to extract the correct time and date defaults for a
350-
# couple of reasons.
351-
# 1) There's a bug in CockroachDB where the date type is missing from
352-
# the column info query.
353-
# https://github.com/cockroachdb/cockroach/issues/47285
354-
# 2) PostgreSQL's timestamp without time zone type maps to CockroachDB's
355-
# TIMESTAMP type. TIMESTAMP includes a UTC time zone while timestamp
356-
# without time zone doesn't.
357-
# https://www.cockroachlabs.com/docs/v19.2/timestamp.html#variants
358-
def extract_time_from_default(default)
359-
return unless default =~ /\A'(.*)'\z/
360-
361-
# If default has a UTC time zone, we'll drop the time zone information
362-
# so it acts like PostgreSQL's timestamp without time zone. Then, try
363-
# to parse the resulting string to verify if it's a time.
364-
time = if default =~ /\A'(.*)(\+00:00)'\z/
365-
$1
366-
else
367-
default
368-
end
369-
370-
Time.parse(time).to_s
371-
rescue
372-
nil
373-
end
374-
375348
# CockroachDB stores default values for arrays in the `ARRAY[...]` format.
376349
# In general, it is hard to parse that, but it is easy to handle the common
377350
# case of an empty array.

0 commit comments

Comments
 (0)