datamapper/dm-types — Issue #51: dm-types redefines the global CSV constant on Ruby 1.8
Author: rsutphin
Created: 2011-12-13 15:33:24+00:00
State: open

`dm-types/csv.rb` redefines the global `CSV` constant to be an alias to `FasterCSV` when running under Ruby 1.8. While I understand the desire to keep the remainder of the code the same under 1.8 and 1.9, this causes a problem: if the built-in CSV library is required after `dm-types/csv.rb` (e.g., by another library) you get a `superclass mismatch for class Row` error.

An alternative: define a method on that returns the appropriate module to use (CSV or FasterCSV) depending on the ruby version.

dm-serializer has a similar bug (datamapper/dm-serializer#25). The bug in dm-types is less serious since `dm-types/csv.rb` is only required if you actually use the `Csv` type, but it is still a potential issue.