Uploaded image for project: 'PHP Driver: Extension'
  1. PHP Driver: Extension
  2. PHPC-2079

Consolidate _id extraction in BulkWrite::insert()

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None

      The bson_out parameter for php_phongo_zval_to_bson() dates back to e619946 in the earliest version of the extension. This is only used by BulkWrite::insert() to return the _id value, which may be generated during BSON encoding.

      Looking at the implementation, I don't believe there is any reason this needs to be handed in phongo_bson_encode.c. Instead, BulkWrite::insert() can extract the _id field on its own. Since PHONGO_BSON_ADD_ID is used during encoding, we can safely assume that the identifier will be inserted if it does not already exist (i.e. it should always exist in the encoded bson_t).

      The PHONGO_BSON_RETURN_ID flag can also be removed.

            Assignee:
            Unassigned Unassigned
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: