Repository navigation
Conversation
Co-authored-by: Copilot <copilot@github.com>
|
It might be better to separate these changes in two PRs, but some comments here. Property based data accessThe Dict typeHave you considered surfacing this as |
|
Thanks for answering:
Leaving both getindex methods with String key and Symbol key could be interesting. People who are sure that they don't overwrite or call merge! explicitly can benefit from less iteration, if String keys always returns the first entry. Questions to be answered_
Concerning your question with BSONIterator, you're probably right, but I'm at the beginning of using the package and didn't have the need to use BSONIterator yet. Concerning your proposal of OrderedDict(::BSON) is indeed tempting, why not defining EDIT: One more question: |
quinnj
left a comment
There was a problem hiding this comment.
Fresh review of unchanged head e98171fad79aaa061fb66b9c2b186b44ae792b18 found two mutation/ownership defects and one selector defect, reproduced on both minimum Julia 1.6.7 and current 1.13.1. The nine focused assertions give five passes and four failures on each version; the nested OrderedDict support itself passes. No MongoDB server is needed for these BSON reproductions. The fork branch was left unchanged. No Actions run or check results are available for this exact head, so I am not claiming full CI validation.
AI disclosure: This work was prepared with assistance from OpenAI Codex.
| vv = document[index] | ||
| # replace the dummy value by the real value | ||
| vv[k_pos] = value | ||
| bson_reinit(document) |
There was a problem hiding this comment.
[P1] Preserve the document when an assigned value cannot be encoded
d = Mongoc.BSON("a" => Int32(1), "b" => "keep"); d.a = big(2) throws a MethodError after this bson_reinit, leaving d empty and losing both original fields. I reproduced this on Julia 1.6.7 and 1.13.1. Build and validate the replacement in a separate BSON first, then commit it to the original only after successful encoding. Otherwise an ordinary unsupported value destroys unrelated data.
AI disclosure: This work was prepared with assistance from OpenAI Codex.
| end | ||
|
|
||
| function Base.setproperty!(document::BSON, key::Symbol, value::Ptr{Nothing}) | ||
| setfield!(document, :handle, value) |
There was a problem hiding this comment.
[P1] Limit native-handle assignment to the handle property
This overload ignores key. d.unrelated = C_NULL silently replaces the live native handle even though the caller did not write the handle property. I reproduced the pointer replacement on Julia 1.6.7 and 1.13.1, restoring the saved live pointer before any native operation. The original allocation becomes unreachable and later document access operates on the replacement pointer. Restrict this compatibility path to key === :handle; other pointer-valued document properties should follow normal value validation.
AI disclosure: This work was prepared with assistance from OpenAI Codex.
| vv = Vector{Any}(undef, n) | ||
| while(bson_iter_next(iter_ref)) | ||
| i += 1 | ||
| if i ∈ index |
There was a problem hiding this comment.
[P2] Handle Boolean selectors before treating indices as positions
Mongoc.BSON("a" => Int32(1), "b" => Int32(2))[[false, true]] raises UndefRefError on Julia 1.6.7 and 1.13.1. Membership treats true as position 1, so slot 2 stays uninitialized, but the final Boolean indexing selects slot 2. Normalize Boolean masks to positions, or reject them explicitly if this helper only supports integer positions.
AI disclosure: This work was prepared with assistance from OpenAI Codex.
This PR is in most parts identical to #151 but it makes
DEFAULT_DICT_TYPEa true constant and converts all property calls tobson.handleto calls likehandle(bson), wherebsonis any variable of typeBSON.This is inspired by #146.