feat(tables): import csv into existing tables#4199
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Introduces shared Wires a new Reviewed by Cursor Bugbot for commit 1a45b8e. Configure here. |
Greptile SummaryThis PR adds CSV import into existing tables — with append/replace modes and configurable column mapping — through a new All remaining findings are P2: two instances of subpath imports instead of the Confidence Score: 5/5Safe to merge — no blocking issues; only minor style/duplication P2 findings. All P2. The core implementation is correct: the replace path uses a transactional FOR UPDATE lock, query invalidation covers rows + count + lists, validation catches required columns, unique constraints, and capacity before writing, and test coverage is thorough across both the route and the shared library. import-csv-dialog.tsx (barrel import style) and hooks/queries/tables.ts (duplicate type declarations) Important Files Changed
Sequence DiagramsequenceDiagram
actor User
participant Dialog as ImportCsvDialog
participant Hook as useImportCsvIntoTable
participant API as POST /api/table/[tableId]/import-csv
participant CsvLib as lib/table/csv-import
participant Service as lib/table/service
User->>Dialog: Select CSV file
Dialog->>CsvLib: parseCsvBuffer(Uint8Array)
CsvLib-->>Dialog: { headers, rows }
Dialog->>CsvLib: buildAutoMapping(headers, schema)
CsvLib-->>Dialog: mapping
Dialog-->>User: Show column mapping UI
User->>Dialog: Confirm import (append | replace)
Dialog->>Hook: mutateAsync({ tableId, file, mode, mapping })
Hook->>API: POST FormData
API->>API: checkSessionOrInternalAuth
API->>API: checkAccess(tableId, userId, write)
API->>CsvLib: parseCsvBuffer(Buffer)
CsvLib-->>API: { headers, rows }
API->>CsvLib: buildAutoMapping / validateMapping
CsvLib-->>API: validation result
API->>CsvLib: coerceRowsForTable(rows, schema, effectiveMap)
CsvLib-->>API: coerced RowData[]
alt mode = append
API->>Service: batchInsertRows (in batches of 1000)
Service-->>API: inserted rows
else mode = replace
API->>Service: replaceTableRows (transactional DELETE + INSERT)
Service-->>API: { deletedCount, insertedCount }
end
API-->>Hook: { success, data }
Hook->>Hook: invalidateRowCount (rows + detail + lists)
Hook-->>Dialog: result
Dialog-->>User: toast + close
|
|
bugbot run |
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1a45b8e. Configure here.

Summary
Import csv into existing tables with configurable mapping of columns. Can append to table [checking uniqueness constraints] or replace rows.
Also added capability to mothership.
Type of Change
Testing
Tested manually.
Checklist