lib/active_record/connection_adapters/cockroachdb_adapter.rb
# This method exists to extract the correct time and date defaults for a
# couple of reasons.
# 1) There's a bug in CockroachDB where the date type is missing from
# the column info query.
# https://github.com/cockroachdb/cockroach/issues/47285
# 2) PostgreSQL's timestamp without time zone type maps to CockroachDB's
# TIMESTAMP type. TIMESTAMP includes a UTC time zone while timestamp
# without time zone doesn't.
# https://www.cockroachlabs.com/docs/v19.2/timestamp.html#variants
This method exists to extract the correct time and date defaults for a
couple of reasons.
1) There's a bug in CockroachDB where the date type is missing from
the column info query.
This method exists to extract the correct time and date defaults for a couple of reasons . 1 ) There ' s a bug in CockroachDB where the date type is missing from the column info query .
def extract_time_from_default(default)
          return unless default =~ /\A'(.*)'\z/
          time = if default =~ /\A'(.*)(\+00:00)'\z/
            $1
          else
            default
          end
          Time.parse(time).to_s
        rescue
          nil
        end
def extract_time_from_default ( default ) return unless default =~ / \A '(.*)' \z / time = if default =~ / \A '(.*)( \+ 00:00)' \z / $1 else default end Time . parse ( time ) . to_s rescue nil end
This method exists to extract the correct time and date defaults for a
couple of reasons.
This method exists to extract the correct time and date defaults for a couple of reasons .
# If default has a UTC time zone, we'll drop the time zone information # so it acts like PostgreSQL's timestamp without time zone. Then, try # to parse the resulting string to verify if it's a time.
default
<not_specific>