Skip to content

Commit b56dd4a

Browse files
BuonOmorafiss
authored andcommitted
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
1 parent 338200d commit b56dd4a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/active_record/connection_adapters/cockroachdb_adapter.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ def column_definitions(table_name)
427427
fields.map do |field|
428428
dtype = field[f_type]
429429
field[f_type] = crdb_fields[field[f_attname]][2].downcase if re.match(dtype)
430-
field[f_comment] = crdb_fields[field[f_attname]][1]&.gsub!(/^\'|\'?$/, '')
430+
field[f_comment] = crdb_fields[field[f_attname]][1]
431431
field[f_is_hidden] = true if crdb_fields[field[f_attname]][3]
432432
field
433433
end
@@ -455,9 +455,8 @@ def crdb_column_definitions(table_name)
455455
WHERE c.table_name = #{quote(table)}#{with_schema}
456456
SQL
457457

458-
fields.reduce({}) do |a, e|
459-
a[e[0]] = e
460-
a
458+
fields.to_h do |field|
459+
[field.first, field]
461460
end
462461
end
463462

0 commit comments

Comments
 (0)