lib/active_record/connection_adapters/cockroachdb_adapter.rb
# Both PostgreSQL and CockroachDB use C-style string escapes under the
# covers. PostgreSQL obscures this for us and unescapes the strings, but
# CockroachDB does not. Here we'll use Ruby to unescape the string.
# See https://github.com/cockroachdb/cockroach/issues/47497 and
# https://www.postgresql.org/docs/9.2/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-ESCAPE.
Both PostgreSQL and CockroachDB use C-style string escapes under the
covers. PostgreSQL obscures this for us and unescapes the strings, but
CockroachDB does not. Here we'll use Ruby to unescape the string.
Both PostgreSQL and CockroachDB use C - style string escapes under the covers . PostgreSQL obscures this for us and unescapes the strings but CockroachDB does not . Here we ' ll use Ruby to unescape the string .
def extract_escaped_string_from_default(default)
          return unless default =~ /\A[\(B]?e'(.*)'.*::"?([\w. ]+)"?(?:\[\])?\z/m
          "\"#{$1}\"".undump.gsub("\\'".freeze, "'".freeze)
        end
def extract_escaped_string_from_default ( default ) return unless default =~ / \A [ \( B]?e'(.*)'.*::"?([ \w . ]+)"?(?: \[ \] )? \z /m "\"#{$1}\"" . undump . gsub ( "\\'" . freeze , "'" . freeze ) end
Both PostgreSQL and CockroachDB use C-style string escapes under the
covers.
Both PostgreSQL and CockroachDB use C - style string escapes under the covers .
# Escaped strings start with an e followed by the string in quotes (e'…') # String#undump doesn't account for escaped single quote characters
default
<not_specific>