Skip to content

Commit 7a8c102

Browse files
bjoriderickr
authored andcommitted
_id doesn't have to be object
1 parent 28cdce1 commit 7a8c102

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/bson.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,11 @@ PHONGO_API void zval_to_bson(zval *data, php_phongo_bson_flags_t flags, bson_t *
11771177
}
11781178
phongo_bson_append(bson, flags & ~PHONGO_BSON_ADD_ID, skey, skey_len, Z_TYPE_P(value), value TSRMLS_CC);
11791179
} else {
1180+
if (flags & PHONGO_BSON_ADD_ID) {
1181+
if (!strncmp(key->val, "_id", sizeof("_id")-1)) {
1182+
flags &= ~PHONGO_BSON_ADD_ID;
1183+
}
1184+
}
11801185
phongo_bson_append(bson, flags & ~PHONGO_BSON_ADD_ID, key->val, key->len, Z_TYPE_P(value), value TSRMLS_CC);
11811186
}
11821187
} else {

0 commit comments

Comments
 (0)