Skip to content

Commit f4631e6

Browse files
rafissBuonOmo
andauthored
fix: do not alter user comments (#384)
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 Co-authored-by: Ulysse Buonomo <[email protected]>
1 parent de4946c commit f4631e6

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
@@ -407,7 +407,7 @@ def column_definitions(table_name)
407407
fields.map do |field|
408408
dtype = field[1]
409409
field[1] = crdb_fields[field[0]][2].downcase if re.match(dtype)
410-
field[7] = crdb_fields[field[0]][1]&.gsub!(/^\'|\'?$/, '')
410+
field[7] = crdb_fields[field[0]][1]
411411
field[10] = true if crdb_fields[field[0]][3]
412412
field
413413
end
@@ -438,9 +438,8 @@ def crdb_column_definitions(table_name)
438438
WHERE c.table_name = #{quote(table)}#{with_schema}
439439
SQL
440440

441-
fields.reduce({}) do |a, e|
442-
a[e[0]] = e
443-
a
441+
fields.to_h do |field|
442+
[field.first, field]
444443
end
445444
end
446445

0 commit comments

Comments
 (0)