Running Ruby 1.8.6 on Edge Rails r6500, Mac OS X 10.4.9:
Trying to load binary data from test fixtures currently fails on many database servers. This is because of an error in the fixture loading code that causes table column types to go unrecognized. Because ActiveRecord doesn't know the column type it also doesn't know how to properly quote the fixture data. Finally, the SQL statements will go awry.
This problem shows up with :binary columns because binary input typically require special data escaping beyond basic string escaping. Such escaping is done in the database adapters' #quote method, which needs a properly detected column type to function correctly.
The current code calls #kind_of? on a constantized class to test for a superclass. This is incorrect. The following irb snippet shows why:
irb(main):001:0> class Person; end
=> nil
irb(main):002:0> class Father < Person; end
=> nil
irb(main):003:0> dad = Father.new
=> #<Father:0x89314>
irb(main):004:0> dad.kind_of?(Person)
=> true
irb(main):005:0> Father.kind_of?(Person)
=> false
irb(main):006:0> Father.ancestors.include?(Person)
=> true
The attached patch corrects the code to use #ancestors.include? and adds corresponding tests.
I've tested MySQL 5.0.37, PostgreSQL 8.2.3, SQLite 2.8.17, and SQLite 3.3.13. Only MySQL did not exhibit the issue, all three others did. The included test case passes on all four databases.