Skip to content

Conversation

@andynu
Copy link
Collaborator

@andynu andynu commented Jan 26, 2026

Summary

  • Fix CLOB/BLOB data loss when prepared_statements: false
  • Skip redundant LOB writes when prepared_statements: true

This commonly occurs in Rails 8 development environments where config.active_record.query_log_tags_enabled = true (the default) causes Rails to automatically disable prepared statements.

Changes

  • Add before_create :record_lobs_for_create callback
  • Add after_create :enhanced_write_lobs callback
  • Add record_lobs_for_create method to track non-nil LOB columns on create
  • Skip callback when prepared_statements is enabled (LOB data already written via temporary LOB binding in type_cast())

Test plan

  • Existing specs pass
  • New specs added for CLOB creation with prepared_statements: false

Fixes #2477
Fixes #2483

When prepared_statements is disabled, INSERT statements use empty_clob()/
empty_blob() literals instead of bind parameters. The LOB module previously
only had after_update callbacks, causing LOB data to be lost on INSERT.

This commonly occurs in Rails 8 development environments where
config.active_record.query_log_tags_enabled = true (the default) causes
Rails to automatically disable prepared statements.

Changes:
- Add before_create :record_lobs_for_create callback
- Add after_create :enhanced_write_lobs callback
- Add record_lobs_for_create method to track non-nil LOB columns on create
- Skip callback when prepared_statements is enabled (LOB data already
  written via temporary LOB binding in type_cast())

Fixes rsim#2477 (CLOBs empty after creation)
Fixes rsim#2483 (redundant double-write with prepared statements)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLOB/BLOB Inserts Fail When prepared_statements: false (which happens when config.active_record.query_log_tags_enabled = true)

1 participant