* BuildUpdateSpecList iterates over an array of update operations and * builds a Update for each object. */
| 903 | * builds a Update for each object. |
| 904 | */ |
| 905 | static List * |
| 906 | BuildUpdateSpecList(bson_iter_t *updateArrayIter, bool *hasUpsert, |
| 907 | const bson_value_t *variableSpec) |
| 908 | { |
| 909 | List *updates = NIL; |
| 910 | |
| 911 | while (bson_iter_next(updateArrayIter)) |
| 912 | { |
| 913 | StringInfo fieldNameStr = makeStringInfo(); |
| 914 | int arrIdx = list_length(updates); |
| 915 | appendStringInfo(fieldNameStr, "update.updates.%d", arrIdx); |
| 916 | |
| 917 | EnsureTopLevelFieldType(fieldNameStr->data, updateArrayIter, BSON_TYPE_DOCUMENT); |
| 918 | |
| 919 | bson_iter_t updateOperationIter; |
| 920 | bson_iter_recurse(updateArrayIter, &updateOperationIter); |
| 921 | |
| 922 | UpdateSpec *update = BuildUpdateSpec(&updateOperationIter, variableSpec); |
| 923 | |
| 924 | updates = lappend(updates, update); |
| 925 | |
| 926 | if (update->updateOneParams.isUpsert) |
| 927 | { |
| 928 | *hasUpsert = true; |
| 929 | } |
| 930 | } |
| 931 | ReportUpdateFeatureUsage(list_length(updates)); |
| 932 | return updates; |
| 933 | } |
| 934 | |
| 935 | |
| 936 | /* |
no test coverage detected