From e3636d072e58119490c9ca82efbf23a449a4fd78 Mon Sep 17 00:00:00 2001 From: Ulysse Buonomo Date: Mon, 18 Aug 2025 12:24:18 +0200 Subject: [PATCH] fix: do not alter user comments We used to have a regex that removed the first and last single quotes from a comment. There is no information about this decision, nor any related test. This might have been a difference between PostgreSQL and CockroachDB. Since tests are passing without it, and comments are not quoted, we can remove the regex. Moreover, if a comment would start or end with a single quote, this would remove that quote, which is not desirable. Fixes #381 --- .../connection_adapters/cockroachdb_adapter.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/active_record/connection_adapters/cockroachdb_adapter.rb b/lib/active_record/connection_adapters/cockroachdb_adapter.rb index 82944169..3a98cbff 100644 --- a/lib/active_record/connection_adapters/cockroachdb_adapter.rb +++ b/lib/active_record/connection_adapters/cockroachdb_adapter.rb @@ -427,7 +427,7 @@ def column_definitions(table_name) fields.map do |field| dtype = field[f_type] field[f_type] = crdb_fields[field[f_attname]][2].downcase if re.match(dtype) - field[f_comment] = crdb_fields[field[f_attname]][1]&.gsub!(/^\'|\'?$/, '') + field[f_comment] = crdb_fields[field[f_attname]][1] field[f_is_hidden] = true if crdb_fields[field[f_attname]][3] field end @@ -455,9 +455,8 @@ def crdb_column_definitions(table_name) WHERE c.table_name = #{quote(table)}#{with_schema} SQL - fields.reduce({}) do |a, e| - a[e[0]] = e - a + fields.to_h do |field| + [field.first, field] end end