Refuse overlapping reference reads across a record's columns, keep an empty column a CSV row, and reject an empty --table
Tests / vet + fmt + tests (pull_request) Successful in 1m4s

This commit is contained in:
2026-09-04 09:10:03 +02:00
parent be5dfdf977
commit c612c9e734
3 changed files with 83 additions and 14 deletions
+4 -3
View File
@@ -216,9 +216,7 @@ type recordFormat struct {
line func(r *fejkdata.Record, table string) string
}
// recordFormats is every --format that writes records. Adding one is this entry
// alone: the flag check reads the same table the writer dispatches through, so a
// format cannot be accepted and then not written.
// recordFormats is every --format that writes records.
var recordFormats = map[string]recordFormat{
"csv": {header: (*fejkdata.Record).CSVHeader, line: func(r *fejkdata.Record, _ string) string { return r.CSVLine() }},
"json": {line: func(r *fejkdata.Record, _ string) string { return r.JSON() }},
@@ -245,6 +243,9 @@ func (in invocation) checkFlags() error {
if _, ok := recordFormats[in.format]; !ok && in.format != "text" {
return fmt.Errorf("--format takes %s, got %q", formatNames(), in.format)
}
if in.tableSet && in.table == "" {
return errors.New("--table names the INSERT target, so it cannot be empty")
}
if in.tableSet && in.format != "sql" {
return errors.New("--table names the INSERT target, so it needs --format sql")
}