Ticket #9239: fixtures_using_correct_connection.patch
| File fixtures_using_correct_connection.patch, 1.3 kB (added by theamazingrando, 1 year ago) |
|---|
-
lib/active_record/fixtures.rb
old new 282 282 @table_name = class_name.table_name if class_name.respond_to?(:table_name) 283 283 @connection = class_name.connection if class_name.respond_to?(:connection) 284 284 read_fixture_files 285 285 286 end 286 287 287 288 def delete_existing_fixtures … … 394 395 end 395 396 396 397 @class_name = class_name 398 @connection = class_name.respond_to?(:connection) ? class_name.connection : ActiveRecord::Base.connection 397 399 end 398 400 399 401 def each … … 409 411 end 410 412 411 413 def key_list 412 columns = @fixture.keys.collect{ |column_name| ActiveRecord::Base.connection.quote_column_name(column_name) }414 columns = @fixture.keys.collect{ |column_name| @connection.quote_column_name(column_name) } 413 415 columns.join(", ") 414 416 end 415 417 … … 418 420 419 421 list = @fixture.inject([]) do |fixtures, (key, value)| 420 422 col = klass.columns_hash[key] if klass.respond_to?(:ancestors) && klass.ancestors.include?(ActiveRecord::Base) 421 fixtures << ActiveRecord::Base.connection.quote(value, col).gsub('[^\]\\n', "\n").gsub('[^\]\\r', "\r")423 fixtures << @connection.quote(value, col).gsub('[^\]\\n', "\n").gsub('[^\]\\r', "\r") 422 424 end 423 425 list * ', ' 424 426 end