Ticket #7987: ora_binary_fixtures.patch
| File ora_binary_fixtures.patch, 4.6 kB (added by mschoen, 1 year ago) |
|---|
-
activerecord/test/binary_test.rb
old new 20 20 # Without using prepared statements, it makes no sense to test 21 21 # BLOB data with DB2 or Firebird, because the length of a statement 22 22 # is limited to 32KB. 23 unless %w(SQLServer Sybase DB2 Oracle Firebird).include? ActiveRecord::Base.connection.adapter_name23 unless current_adapter?(:SQLServerAdapter, :SybaseAdapter, :DB2Adapter, :FirebirdAdapter) 24 24 def test_load_save 25 25 bin = Binary.new 26 26 bin.data = @data -
activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
old new 119 119 # Do nothing by default. Implement for PostgreSQL, Oracle, ... 120 120 end 121 121 122 # Inserts the given fixture into the table. Overriden in adapters that require 123 # something beyond a simple insert (eg. Oracle). 124 def insert_fixture(fixture, table_name) 125 execute "INSERT INTO #{table_name} (#{fixture.key_list}) VALUES (#{fixture.value_list})", 'Fixture Insert' 126 end 127 122 128 protected 123 129 # Returns an array of record hashes with the column names as keys and 124 130 # column values as values. -
activerecord/lib/active_record/connection_adapters/oracle_adapter.rb
old new 44 44 # After setting large objects to empty, select the OCI8::LOB 45 45 # and write back the data. 46 46 after_save :write_lobs 47 def write_lobs ()#:nodoc:47 def write_lobs #:nodoc: 48 48 if connection.is_a?(ConnectionAdapters::OracleAdapter) 49 self.class.columns.select { |c| c.sql_type =~ /LOB$/i }.each { |c| 50 value = self[c.name] 51 value = value.to_yaml if unserializable_attribute?(c.name, c) 52 next if value.nil? || (value == '') 53 lob = connection.select_one( 54 "SELECT #{c.name} FROM #{self.class.table_name} WHERE #{self.class.primary_key} = #{quote_value(id)}", 55 'Writable Large Object')[c.name] 56 lob.write value 57 } 49 connection.write_lobs(self.class.table_name, self.class, attributes) 58 50 end 59 51 end 60 52 … … 273 265 end 274 266 275 267 268 # Inserts the given fixture into the table. Overriden to properly handle lobs. 269 def insert_fixture(fixture, table_name) 270 super 271 272 klass = fixture.class_name.constantize rescue nil 273 if klass.respond_to?(:ancestors) && klass.ancestors.include?(ActiveRecord::Base) 274 write_lobs(table_name, klass, fixture) 275 end 276 end 277 278 # Writes LOB values from attributes, as indicated by the LOB columns of klass. 279 def write_lobs(table_name, klass, attributes) 280 id = quote(attributes[klass.primary_key]) 281 klass.columns.select { |col| col.sql_type =~ /LOB$/i }.each do |col| 282 value = attributes[col.name] 283 value = value.to_yaml if col.text? && klass.serialized_attributes[col.name] 284 next if value.nil? || (value == '') 285 lob = select_one("SELECT #{col.name} FROM #{table_name} WHERE #{klass.primary_key} = #{id}", 286 'Writable Large Object')[col.name] 287 lob.write value 288 end 289 end 290 291 276 292 # SCHEMA STATEMENTS ======================================== 277 293 # 278 294 # see: abstract/schema_statements.rb -
activerecord/lib/active_record/fixtures.rb
old new 290 290 291 291 def insert_fixtures 292 292 values.each do |fixture| 293 @connection. execute "INSERT INTO #{@table_name} (#{fixture.key_list}) VALUES (#{fixture.value_list})", 'Fixture Insert'293 @connection.insert_fixture fixture, @table_name 294 294 end 295 295 end 296 296 … … 381 381 class FormatError < FixtureError#:nodoc: 382 382 end 383 383 384 attr_reader :class_name 385 384 386 def initialize(fixture, class_name) 385 387 case fixture 386 388 when Hash, YAML::Omap