From: adam Date: Fri, 14 Dec 2012 08:25:12 +0000 (+0700) Subject: v1.0.27 X-Git-Tag: v1.2.12~571 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9f35449191bcf5f95233e94e102366d1b8ae1a4b;p=platform%2Fupstream%2Fejdb.git v1.0.27 --- diff --git a/Changelog b/Changelog index 4f63ad3..aacfd19 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,6 @@ 2012-12-14 Anton Adamansky. * Added `$addToSet` and `$pull` operations. - - Release 1.0.26 + - Release 1.0.27 2012-12-04 Anton Adamansky. * Allows multiple matching conditions for single query field. Eg: {'age' : {'$lt' : '60', '$gt' : '30'}} diff --git a/package.json b/package.json index d15baef..30e1d70 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name" : "ejdb", - "version" : "1.0.26", + "version" : "1.0.27", "main" : "node/ejdb.js", "description" : "EJDB - Embedded JSON Database engine", "homepage" : "http://ejdb.org", diff --git a/tcejdb/bson.c b/tcejdb/bson.c index 1e73bd5..f91c111 100644 --- a/tcejdb/bson.c +++ b/tcejdb/bson.c @@ -1557,6 +1557,33 @@ EJDB_EXPORT bson* bson_create_from_buffer2(bson *rv, const void* buf, int bufsz) return rv; } +EJDB_EXPORT bool bson_find_merged_array_sets(const void *mbuf, const void *inbuf) { + assert(mbuf && inbuf); + bool found = false; + bson_iterator it, it2; + bson_type bt, bt2; + bson_iterator_from_buffer(&it, mbuf); + while ((bt = bson_iterator_next(&it)) != BSON_EOO) { + bson_iterator_from_buffer(&it2, inbuf); + bt2 = bson_find_fieldpath_value(bson_iterator_key(&it), &it2); + if (bt2 != BSON_ARRAY) { + continue; + } + bson_iterator sit; + bson_iterator_subiterator(&it2, &sit); + while ((bt2 = bson_iterator_next(&sit)) != BSON_EOO) { + if (!bson_compare_it_current(&sit, &it)) { + found = true; + break; + } + } + if (found) { + break; + } + } + return found; +} + EJDB_EXPORT bool bson_find_unmerged_array_sets(const void *mbuf, const void *inbuf) { assert(mbuf && inbuf); bool allfound = false; diff --git a/tcejdb/bson.h b/tcejdb/bson.h index e041d57..da79dce 100644 --- a/tcejdb/bson.h +++ b/tcejdb/bson.h @@ -1129,6 +1129,7 @@ EJDB_EXPORT bson* bson_create_from_buffer(const void *buf, int bufsz); EJDB_EXPORT bson* bson_create_from_buffer2(bson *bs, const void *buf, int bufsz); EJDB_EXPORT bool bson_find_unmerged_array_sets(const void *mbuf, const void *inbuf); +EJDB_EXPORT bool bson_find_merged_array_sets(const void *mbuf, const void *inbuf); EJDB_EXPORT int bson_merge_array_sets(const void *mbuf, const void *inbuf, bool pull, bson *bsout); diff --git a/tcejdb/ejdb.c b/tcejdb/ejdb.c index 5ae6b94..d6997d7 100644 --- a/tcejdb/ejdb.c +++ b/tcejdb/ejdb.c @@ -1753,7 +1753,7 @@ static bool _qryupdate(EJCOLL *jcoll, const EJQ *ejq, void *bsbuf, int bsbufsz, if (pullqf) { //$pull char* inbuf = (bsout.finished) ? bsout.data : bsbuf; - if (!bson_find_unmerged_array_sets(bson_data(pullqf->updateobj), inbuf)) { + if (bson_find_merged_array_sets(bson_data(pullqf->updateobj), inbuf)) { if (bsout.finished) { //reinit `bsout`, `inbuf` already points to `bsout.data` and will be freed later bson_init_size(&bsout, bson_size(&bsout));