Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getproperty on File makes internal use of dot notation problematic #1080

Closed
albheim opened this issue Apr 20, 2023 · 1 comment
Closed

getproperty on File makes internal use of dot notation problematic #1080

albheim opened this issue Apr 20, 2023 · 1 comment

Comments

@albheim
Copy link
Contributor

albheim commented Apr 20, 2023

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.

@albheim albheim changed the title File getproperty getproperty on File makes internal use of dot notation problematic Apr 20, 2023
@albheim
Copy link
Contributor Author

albheim commented Apr 23, 2023

Solved by #1081

@albheim albheim closed this as completed Apr 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant