Skip to content

Commit 151e629

Browse files
committed
Skip write_lobs callback when using prepared statements
When prepared_statements is enabled (the default), LOB data is already written during INSERT via temporary LOB binding in type_cast(). The write_lobs callback was redundantly writing the same data again via SELECT FOR UPDATE. This change skips the callback in the prepared statements path while preserving it for the unprepared path, where empty_clob()/empty_blob() literals require the callback to populate LOB data after INSERT. Fixes the double-write issue identified in #2483.
1 parent eb734d8 commit 151e629

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

  • lib/active_record/connection_adapters/oracle_enhanced

lib/active_record/connection_adapters/oracle_enhanced/lob.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ def lob_columns
2727

2828
private
2929
def enhanced_write_lobs
30+
# Skip if using prepared statements - LOB data is already written via temp LOB binding
31+
return if self.class.connection.prepared_statements
32+
3033
if self.class.connection.is_a?(ConnectionAdapters::OracleEnhancedAdapter) &&
3134
!(self.class.custom_create_method || self.class.custom_update_method)
3235
self.class.connection.write_lobs(self.class.table_name, self.class, attributes, @changed_lob_columns)

0 commit comments

Comments
 (0)