Skip to content

Comments

Track SQL write events and verify cache dumping coverage#18

Merged
ngan merged 6 commits intomainfrom
np-sql-subscriber-create-update-events
Feb 23, 2026
Merged

Track SQL write events and verify cache dumping coverage#18
ngan merged 6 commits intomainfrom
np-sql-subscriber-create-update-events

Conversation

@ngan
Copy link
Collaborator

@ngan ngan commented Feb 23, 2026

Summary

  • stop parsing SQL text in FixtureKit::SqlSubscriber
  • track changed models from sql.active_record payload name events, including:
    • Create
    • Update / Update All
    • Destroy / Delete All
    • Insert / Bulk Insert
    • Upsert / Bulk Upsert
  • restore tracked tables via batch statements under referential-integrity suspension:
    • DELETE FROM <table> first
    • then replay cached INSERT SQL when present
  • remove conflict-handling SQL variants (INSERT OR IGNORE, ON CONFLICT DO NOTHING, INSERT IGNORE)
  • allow empty changed tables by storing nil insert SQL for that model

Test Coverage Added

  • spec/unit/fixture_cache_spec.rb
    • update-only writes
    • delete-only writes
    • changed table becomes empty
    • documents execute_batch visibility assumption (currently private)
  • spec/unit/sql_subscriber_spec.rb
    • asserts SqlSubscriber.capture includes changed model for supported write operations
    • asserts exact Rails payload[:name] format assumptions for supported operations
  • Dummy app integration coverage for query types in both RSpec and Minitest:
    • new fixture: spec/dummy/fixture_kit/query_type_events.rb
    • verifies cache records include all touched tables/models for each supported query type
    • adds integration marker FKIT_ASSERT:QUERY_TYPES_CAPTURED

Why

  • payload-name tracking avoids brittle SQL parsing
  • delete semantics are now represented by clearing tracked tables before replay
  • explicit format-assertion tests make Rails event-name changes visible immediately

Testing

  • bundle exec rspec --fail-fast
  • FIXTURE_KIT_INTEGRATION_FRAMEWORK=minitest bundle exec rspec --fail-fast
  • bundle exec rspec --fail-fast spec/integration/dummy_app_spec.rb
  • FIXTURE_KIT_INTEGRATION_FRAMEWORK=minitest bundle exec rspec --fail-fast spec/integration/dummy_app_spec.rb

@ngan ngan changed the title Track create/update changes from sql.active_record payload names Track create/update/delete events and restore via table reset Feb 23, 2026
@ngan ngan changed the title Track create/update/delete events and restore via table reset Track SQL write events and verify cache dumping coverage Feb 23, 2026
@ngan ngan merged commit c508d3b into main Feb 23, 2026
8 checks passed
@ngan ngan deleted the np-sql-subscriber-create-update-events branch February 23, 2026 03:40
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.

1 participant