!strcmp("$addToSetAll", fkey) ||
!strcmp("$upsert", fkey) ||
!strcmp("$pull", fkey) ||
- !strcmp("$pullAll", fkey)) {
+ !strcmp("$pullAll", fkey) ||
+ !strcmp("$do", fkey)
+ ) {
if (pqf) { //Top level ops
ret = JBEQERROR;
_ejdbsetecode(jb, ret, __FILE__, __LINE__, __func__);
} else if (!strcmp("$pullAll", fkey)) {
qf.flags |= EJCONDPULL;
qf.flags |= EJCONDALL;
+ } else if (!strcmp("$do", fkey)) {
+ qf.flags |= EJCONDOIT;
}
}
+
if ((qf.flags & (EJCONDSET | EJCONDINC | EJCONDADDSET | EJCONDPULL))) {
assert(qf.updateobj == NULL);
qf.q->flags |= EJQUPDATING;
TCLISTPUSH(qlist, &qf, sizeof (qf));
break;
}
+
+ if (qf.flags & EJCONDOIT) { //$do
+ assert(qf.updateobj == NULL);
+ qf.updateobj = bson_create();
+ bson_init_as_query(qf.updateobj);
+ bson_type sbt;
+ bson_iterator sit;
+ bson_iterator_subiterator(it, &sit);
+ while ((sbt = bson_iterator_next(&sit)) != BSON_EOO) {
+ bson_append_field_from_iterator(&sit, qf.updateobj);
+ }
+ bson_finish(qf.updateobj);
+ if (qf.updateobj->err) {
+ ret = JBEQERROR;
+ _ejdbsetecode(jb, ret, __FILE__, __LINE__, __func__);
+ break;
+ }
+ qf.fpath = strdup(fkey);
+ qf.fpathsz = strlen(qf.fpath);
+ qf.tcop = TDBQTRUE;
+ qf.flags |= EJFEXCLUDED;
+ TCLISTPUSH(qlist, &qf, sizeof (qf));
+ break;
+ }
+
if (!strcmp("$elemMatch", fkey)) {
if (qf.elmatchgrp) { //only one $elemMatch allowed in query field
ret = JBEQERROR;
}
case BSON_OID:
{
+
+ if (isckey) {
+
+ }
+
assert(!qf.fpath && !qf.expr);
qf.ftype = ftype;
TCMALLOC(qf.expr, 25 * sizeof (char));
EJCONDADDSET = 1 << 12, /**> $addToSet Adds value to the array only if its not in the array already. */
EJCONDPULL = 1 << 13, /**> $pull Removes all occurrences of value from field, if field is an array */
EJCONDUPSERT = 1 << 14, /**> $upsert Upsert $set operation */
- EJCONDALL = 1 << 15 /**> 'All' modificator for $pull or $addToSet ($addToSetAll or $pullAll) */
+ EJCONDALL = 1 << 15, /**> 'All' modificator for $pull or $addToSet ($addToSetAll or $pullAll) */
+ EJCONDOIT = 1 << 16 /**> $do query field operation */
};
tclistdel(q1res);
}
+
+void testTicket43() {
+ /*
+ Assuming fpath contains object id (or its string representation).
+ In query results fpath values will be replaced by loaded bson
+ objects with matching oids from collectionname
+
+ {..., $do : {fpath : {$join : 'collectionname'}} }
+
+ */
+}
+
int main() {
setlocale(LC_ALL, "en_US.UTF-8");
(NULL == CU_add_test(pSuite, "testPrimitiveCases1", testPrimitiveCases1)) ||
(NULL == CU_add_test(pSuite, "testTicket29", testTicket29)) ||
(NULL == CU_add_test(pSuite, "testTicket28", testTicket28)) ||
- (NULL == CU_add_test(pSuite, "testTicket38", testTicket38))
+ (NULL == CU_add_test(pSuite, "testTicket38", testTicket38)) ||
+ (NULL == CU_add_test(pSuite, "testTicket43", testTicket43))
) {
CU_cleanup_registry();
return CU_get_error();