[CDRIVER-2526] Impove the BCON_APPEND_CTX() function for being called multiple times to add multiple values to same bson array Created: 03/Mar/18 Updated: 05/Feb/24 |
|
| Status: | Backlog |
| Project: | C Driver |
| Component/s: | libbson |
| Affects Version/s: | 1.9.1, 1.9.2, 1.9.3 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | liuzhongchao | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | bg-rf, neweng | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
linux |
||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Epic Link: | Improve Developer Experience | ||||||||
| Backwards Compatibility: | Minor Change | ||||||||
| Description |
|
While adding elements in a bson array, you should call BCON_APPEND_CTX() , but all elements must be placed in the parameter position at once,just like BCON_APPEND_CTX(query, &ctx, "$each", "[", BCON_INT64((int64_t)num[0]), BCON_INT64((int64_t)num[1]), BCON_INT64((int64_t)num[2]) "]") ; However, the number of array elements is unknown, it's difficult to add all elements in the bson array for just calling BCON_APPEND_CTX() one time; |
| Comments |
| Comment by Rishabh Bisht [ 05/Feb/24 ] | ||||||||||||||||||||||
|
Hi haveTryTwo, can you also try the new API we added with CDRIVER-5064 if that solves your use case? https://mongoc.org/libbson/current/bson_array_builder_t.html#bson-array-builder-t | ||||||||||||||||||||||
| Comment by liuzhongchao [ 03/Apr/18 ] | ||||||||||||||||||||||
|
"bcon_append_ctx_va could be improved to make this code succeed (If we do this it could also resolve | ||||||||||||||||||||||
| Comment by A. Jesse Jiryu Davis [ 03/Mar/18 ] | ||||||||||||||||||||||
|
So, you would like to be able to write code like this?:
Currently this code fails with an assertion error in bcon_append_ctx_va:
However, bcon_append_ctx_va could be improved to make this code succeed. (If we do this it could also resolve |