weixin_39900736 2020-11-22 01:58
浏览 0

Query scoping not working in Collection#delegate_to_model + any set operation

I've been trying to solve this myself, but I don't really know enough about the internals of Query, Collection and Model to make much in the way of informed decisions.

I had a brief discussion with Dan on IRC earlier, who confirmed that this behaviour is not intended.

I've created a really simple git project that you can just clone and run that will demonstrate this bug in a really clear way:

https://github.com/d11wtq/dm-scoped-query-bug

The code just demonstrates that when you chain a class method from the model onto an existing Collection (I think only one that was formed from a Union, though I don't really see any identifying factors as to why), it just returns the result of the class method with all the previous scope thrown away. Chaining the all from the body of the class method corrects the issue, but this isn't really ideal with the conditions are more than just a basic flag and are used in several parts of the code.

I've been hacking around inside of with_scope and with_exclusive_scope, but I think I must be in the wrong place, since nothing I do seems to help (e.g. merging with the entire query instead of just query.options).

This is really stinging us at the moment. We're working around it by avoiding being DRY, but it'd be good to have this fixed. I'd love to resolve this myself too if anybody can offer some advice/pointers. More than happy to be a regular contributor to DM.

该提问来源于开源项目:datamapper/dm-core

  • 写回答

5条回答 默认 最新

  • weixin_39900736 2020-11-22 01:58
    关注

    Confirmed this issue existed in 1.1.0 too.

    评论

报告相同问题?