Skip to content

log_sql: true mode — emit the exact transfer SQL for debugging #37

@sncalvo

Description

@sncalvo

Problem

When imports misbehave in prod ("why did 10 rows silently drop?"), the first thing anyone wants is the exact SQL the gem ran. Right now you have to attach a debugger or subscribe to AR's notification channel.

Proposal

StagingTable.stage(User, log_sql: true) { |s| s.insert(rows) }
# → [staging_table] SQL: CREATE TEMP TABLE staging_users_abc123 ...
# → [staging_table] SQL: INSERT INTO staging_users_abc123 (...) VALUES ...
# → [staging_table] SQL: INSERT INTO users (...) SELECT ... FROM staging_users_abc123 ON CONFLICT ...
  • Emits via the configured logger
  • Truncates very long VALUES lists (...)
  • Global enable via config

Acceptance criteria

  • log_sql: true per-call works
  • config.log_sql = true enables globally
  • Sensitive values masked if config.mask_columns = [:password_digest, :ssn]
  • Pairs with the logger-integration issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions