feat: read SQL query from file with -f/--file flag (#157)#165
Conversation
Code Review🐛 Bug found: Memory leak// Before (leak):
const contents = std.Io.Dir.cwd().readFileAlloc(io.io(), path, **allocator**, .limited(...));The query file contents were allocated on the GPA allocator ( 🐛 Bug found: MissingQuery handler missing
🐛 Missing
|
Council Review — SummaryThree expert models (alpha, gamma) reviewed this PR. Key findings: New issue found: Empty query file → cryptic SQL error (High)When Fix: Added explicit Verified fixes from first reviewBoth councillors confirmed all four earlier fixes (memory leak, MissingQuery handler, InvalidQueryFile variant, empty path guard) are correct and complete. Remaining recommendations (low priority — can be tracked as follow-up issues)
Consensus: Approve ✅Both councillors recommended merging. The implementation is clean, follows codebase conventions, and the critical gaps found (memory leak, empty file) have been addressed. |
- Add conflict checks for -f with --columns/--validate/--sample - Detect multiple -f/--file flags (error: only one allowed) - Trim whitespace from query file before empty check - Add 6 integration tests (157h-157l) for new error paths - Update man page SYNOPSIS with stdin form
Oracle Review — Fixes Applied@oracle found 3 critical bugs and several important gaps. Fixes applied: ✅ Fixed
ℹ️ No fixado (decisión deliberada)
Tests agregados (157h-157l)
Man page
Verificación
|
Summary
Adds
-f <file>/--file <file>flag to read the SQL query from a file instead of the command line.Closes #157
Changes
src/args.zig: Addedquery_filefield toParsedArgs, flag parsing for-f/--file/-f=/--file=, updated usage textsrc/main.zig: Reads query file contents after arg parsing, errors with exit 1 if file can't be readbuild.zig: 6 integration tests covering all flag forms and error caseUsage
sql-pipe -f analysis.sql data.csv cat data.csv | sql-pipe -f analysis.sql sql-pipe --file=query.sql data.csvAcceptance Criteria
-f <file>/--file <file>reads SQL query from file