From 5db302ba4ed23dac7ecf9362e673591add716987 Mon Sep 17 00:00:00 2001 From: Jacob Quinn Date: Sun, 4 Oct 2026 08:28:56 -0600 Subject: [PATCH] Report missing note columns with ArgumentError Interpolate the requested column rather than an undefined variable in the existing error path. Cover Symbol, String and zero-index requests and retain existing table and column notes after those errors. AI disclosure: This work was prepared with assistance from OpenAI Codex. --- src/standardkeys.jl | 2 +- test/runtests.jl | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/standardkeys.jl b/src/standardkeys.jl index 3899107..9be056a 100644 --- a/src/standardkeys.jl +++ b/src/standardkeys.jl @@ -118,7 +118,7 @@ See also: [`note!`](@ref) """ function note(table, column) idx = column isa Union{Signed, Unsigned} ? Int(column) : Tables.columnindex(table, column) - idx == 0 && throw(ArgumentError("column $col not found in table")) + idx == 0 && throw(ArgumentError("column $column not found in table")) if "note" in DataAPI.colmetadatakeys(table, column) return string(DataAPI.colmetadata(table, column, "note")) else diff --git a/test/runtests.jl b/test/runtests.jl index 5f149cb..b4bac10 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -44,6 +44,19 @@ end note!(df, :b, "three", append=true) @test note(df, 2) == "two\nthree" @test colmetadata(df, :b, "note", style=true) == ("two\nthree", :note) + + for column in (:absent, "absent", 0, UInt8(0)) + err = try + note(df, column) + catch exception + exception + end + @test err isa ArgumentError + @test sprint(showerror, err) == "ArgumentError: column $column not found in table" + end + @test note(df) == "two\nthree" + @test note(df, :b) == "two\nthree" + @test names(df) == ["a", "b", "c"] end @testset "unit, unit!, units" begin