Skip to content

Improve SQL error messages with column and row context #81

@vmvarela

Description

@vmvarela

Description

Currently, SQL errors are passed through from SQLite verbatim. Messages like no such column: foo give no context about which CSV field mapping failed or what the table schema looks like, making it hard to debug mismatched field names.

Example

Current:

error: no such column: revenue

Desired:

error: no such column: revenue
  table "t" has columns: id, amount, region, date
  hint: did you mean "amount"?

Acceptance Criteria

  • On SQL error (exit code 3), print the SQLite error message as today
  • Additionally print the list of available column names from PRAGMA table_info(t) to stderr
  • If the missing identifier closely matches an existing column name (edit distance ≤ 2), add a hint: did you mean "<col>"? line
  • On CSV parse errors (exit code 2), include the 1-based row number in the error message
  • New behaviour is reflected in README.md (Exit Codes section and error message examples)
  • Tests cover: unknown column (with available columns printed), CSV parse error with row number

Notes

  • Column list comes from PRAGMA table_info(t) after the table is created
  • Levenshtein / edit-distance can be a small helper function; keep it simple (≤ 2 substitutions)

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:highMust be in the next sprintsize:sSmall — 1 to 4 hoursstatus:readyRefined and ready for sprint selectiontype:featureNew functionality

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions