Hi Jan,

It seems that this is the exact same answer to an other issue I reported, 
but I don't think the issues are related.

Thanks,
Thomas

On Tuesday, June 28, 2016 at 8:57:13 PM UTC+8, Jan wrote:
>
> Hi Thomas,
>
> I used your code to reproduce the issue and it's partly related.
> The problem in this case is not that there are immutable objects, but that 
> the call to `byExample(...).count()` returns an unexpected value.
>
> var fromCount1 = db.foxxdebug.byExample({ _from: from, request: false }).
> count();
>
> The `byExample()` returns an object of type `SimpleQueryByExample`, and 
> when calling `toArray()` on this, the results are correct, before and after 
> the update.
> However, when calling `count()` on that object, this will also correctly 
> execute the simple query, but sometimes returns a wrong result for `count`. 
> The reason for this is that internally the result is produced by an index 
> lookup and then may need to be post-filtered in order to return only those 
> documents that match all conditions. In this case, the byExample will use 
> the edge index on `_from` and then post-filter the result using the 
> `request == false` condition. The result of post-filtering is also correct, 
> however, the `count` value of the query is not adjusted. `count` in this 
> case will return the number of documents before post-filtering. 
>
> In your case the number of documents with the queried `_from` and `_to` 
> values don't change due to the replace, so the `count` values before and 
> after the replace are identical. Clearly it's a bug that the count value is 
> wrong, and I just fixed it in the 2.8 branch. I checked that it's already 
> working fine in 3.0, and 2.8 is the last affected version.
>
> By the way, the workaround to prevent the issue from occurring is to not 
> use `byExample(...).count()` but instead use 
> `byExample(...).toArray().length`.
> We plan to build a new 2.8 release this week end.
>
> Best regards
> Jan
>
> Am Freitag, 24. Juni 2016 15:11:53 UTC+2 schrieb Thomas Weiss:
>>
>> Hi there,
>>
>> I was debugging a different topic in my Foxx app and decided to give the 
>> 'allowImplicit' flag a try (to make sure that all the collections I read in 
>> my transactions were declared). But I found that, even if all collections 
>> are declared, adding this flag would raise an error. Here is a simple 
>> example to reproduce that (tested on 2.8.7):
>>
>> controller.post('/foxxdebug', function (req, res) {
>>     var from = 'foxxdebug/123';
>>     var to = 'foxxdebug/456';
>>     db._executeTransaction({
>>         collections: {
>>             read: ['foxxdebug'],
>>             write: ['foxxdebug'],
>>             allowImplicit: false
>>         },
>>         action: function () {
>>             db.foxxdebug.insert(from, to, {});
>>             var fromCount = db.foxxdebug.byExample({ _from: from }).count
>> ();
>>             var toCount = db.foxxdebug.byExample({ _to: to }).count();
>>             res.json({ fromCount: fromCount, toCount: toCount });
>>         }
>>     });
>> });
>>
>> Note that the 'foxxdebug' was created, but this call would always fail 
>> with the 'unregistered collection used in transaction' error!
>>
>> Thomas
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"ArangoDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to