* BsonUpdateDocument contains the internal implementation of bson_update_document. * returns NULL if no update is needed. */
| 409 | * returns NULL if no update is needed. |
| 410 | */ |
| 411 | pgbson * |
| 412 | BsonUpdateDocument(pgbson *sourceDocument, const bson_value_t *updateSpec, |
| 413 | const bson_value_t *querySpec, const bson_value_t *arrayFilters, |
| 414 | const bson_value_t *variableSpec) |
| 415 | { |
| 416 | BsonUpdateMetadata metadata = { 0 }; |
| 417 | BsonUpdateSource updateSource = { 0 }; |
| 418 | |
| 419 | /* An empty document will be processed as an upsert operation. */ |
| 420 | bool buildSourceDocOnUpsert = IsPgbsonEmptyDocument(sourceDocument); |
| 421 | |
| 422 | BuildBsonUpdateMetadata(&metadata, updateSpec, querySpec, arrayFilters, |
| 423 | variableSpec, buildSourceDocOnUpsert); |
| 424 | return BsonUpdateDocumentCore(sourceDocument, updateSpec, &metadata, &updateSource, |
| 425 | NULL); |
| 426 | } |
| 427 | |
| 428 | |
| 429 | /* |
no test coverage detected