JuliaData/CSV.jl

getproperty on File makes internal use of dot notation problematic

albheim opened this issue · 1 comments

From a discourse thread.

Since getproperty on File is defined to first look up if any field is in the internal lookup table

CSV.jl/src/file.jl

Lines 142 to 145 in cfb4ffb

function Base.getproperty(f::File, col::Symbol)
lookup = getfield(f, :lookup)
return haskey(lookup, col) ? lookup[col].column : getfield(f, col)
end

we get a problem when using getproperty (i.e. dot syntax) to access the fields of the struct, as can be seen here
return File(f.name, f.names, f.types, rows, f.cols, f.columns, f.lookup)

where if any of the column names from from the data read into f (which is type File) shares name with one of the fields that are accessed there, it will likely error or maybe do incorrect things at least.

In the linked thread this happened when one column had the name name, which then errored.

Solved by #1081