feat(bulk): mode, submode and RST are repair fields, so allow them

They were excluded as "per-QSO", alongside callsign and date. That rule confused
two different things: bulk edit is not for describing QSOs, it is for REPAIRING
a batch of them — an import that mapped every contact to SSB, an ADIF that
carried no MODE at all. Refusing because a hundred rows should not normally
share a value left the operator editing a hundred rows by hand.

Setting the mode CLEARS the submode. A submode belongs to the mode it was
recorded under; left behind it contradicts the new one, and "FT8 with a submode
of USB" is not a thing — worse, the submode is what most ADIF readers believe.

Band is still refused on its own, and that half of the rule stands. It travels
with the frequency through BulkSetFrequency, which writes the pair: a band
contradicting its own frequency is invalid ADIF, and every export would carry
the contradiction out into the world. Callsign and date stay out too — they
identify the contact rather than describe it.
This commit is contained in:
2026-08-11 19:36:56 +02:00
parent 3b90ef6b7a
commit 102097c5c4
5 changed files with 82 additions and 12 deletions
+37 -8
View File
@@ -734,13 +734,26 @@ func (r *Repo) MarkEQSLSent(ctx context.Context, id int64, date string) error {
return nil
}
// bulkEditableCols whitelists the columns BulkSetField may write. Limited to
// TEXT fields where setting one value across many QSOs is meaningful: the
// per-service QSL/upload status fields, plus "my station"/operator fields that
// are naturally constant across a run (grid, antenna, rig, address, …). It
// deliberately excludes per-QSO fields (callsign, band, mode, date, RST, the
// contacted station's details) and numeric columns (power, zones, lat/lon),
// which would be corrupted or meaningless if bulk-set to a single value.
// bulkEditableCols whitelists the columns BulkSetField may write.
//
// Mostly TEXT fields where one value across many QSOs is meaningful: the
// per-service QSL/upload status fields, plus "my station"/operator fields
// naturally constant across a run (grid, antenna, rig, address, …).
//
// Mode, submode and RST are here too, which the original rule excluded as
// "per-QSO". That rule confused two different things. Bulk edit is not for
// describing QSOs, it is for REPAIRING a batch — an import that mapped every
// contact to SSB, an ADIF with no MODE at all — and refusing to fix a hundred
// rows because a hundred rows should not normally share a value leaves the
// operator editing them one at a time.
//
// Band is NOT here, and frequency is not either: both go through
// BulkSetFrequency, which writes the pair together. A band that contradicts its
// own frequency is invalid ADIF, and every export would carry the contradiction.
//
// Still excluded, and this part of the rule stands: callsign and date, which
// identify the contact rather than describe it, and the numeric columns (power,
// zones, lat/lon) that are meaningless shared.
var bulkEditableCols = map[string]bool{
// QSL / upload status
"lotw_sent": true,
@@ -820,6 +833,14 @@ var bulkEditableCols = map[string]bool{
"iota": true,
"sig": true,
"sig_info": true,
// The contact itself. Repair fields: an import that mapped everything to SSB,
// or an ADIF that carried no MODE. Setting mode CLEARS submode (see
// BulkSetField) — a submode left over from the old mode contradicts the new
// one, and "FT8 / USB" is not a thing.
"mode": true,
"submode": true,
"rst_sent": true,
"rst_rcvd": true,
// Misc text
"comment": true,
"notes": true,
@@ -843,8 +864,16 @@ func (r *Repo) BulkSetField(ctx context.Context, ids []int64, column, value stri
ph[i] = "?"
args = append(args, id)
}
set := column + " = ?, updated_at = ?"
if column == "mode" {
// A submode belongs to the mode it was recorded under. Left behind, it
// contradicts the new one — "FT8" with a submode of "USB" is not a thing,
// and it is the submode that most ADIF readers believe. Clearing it is the
// only outcome that leaves the row meaning what the operator asked for.
set += ", submode = ''"
}
res, err := r.db.ExecContext(ctx,
`UPDATE qso SET `+column+` = ?, updated_at = ? WHERE id IN (`+strings.Join(ph, ",")+`)`,
`UPDATE qso SET `+set+` WHERE id IN (`+strings.Join(ph, ",")+`)`,
args...)
if err != nil {
return 0, fmt.Errorf("bulk set %s: %w", column, err)