Skip to content

Commit

Permalink
Return a null field for missing fields (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
ancapdev authored Oct 31, 2023
1 parent 4a18665 commit 5fde608
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/reader.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ end
offset = field_end
end
end
throw(KeyError(target))
BSONReader(reader.src, 0, BSON_TYPE_NULL, reader.validator, reader.conversions)
end

# @noinline Base.@constprop :none function Base.getindex(reader::BSONReader, target::Union{AbstractString, Symbol})
Expand Down
2 changes: 1 addition & 1 deletion test/reader_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ end
writer["x"] = 123
close(writer)
reader = BSONReader(buf)
@test_throws KeyError reader["y"]
reader["y"][Any] === nothing
end

@testset "foreach" begin
Expand Down

2 comments on commit 5fde608

@ancapdev
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/94468

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.17 -m "<description of version>" 5fde608af4d6acd252685b3b75bcb696e4cf5b1a
git push origin v0.2.17

Please sign in to comment.