mongodb_ecto
mongodb_ecto copied to clipboard
Fix where in array + dynamic limit and offset
trafficstars
Fixes #170
Pull Request Test Coverage Report for Build 328
- 14 of 15 (93.33%) changed or added relevant lines in 1 file are covered.
- No unchanged relevant lines lost coverage.
- Overall coverage increased (+1.1%) to 87.397%
| Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
|---|---|---|---|
| lib/mongo_ecto/normalized_query.ex | 14 | 15 | 93.33% |
| <!-- | Total: | 14 | 15 |
| Totals | |
|---|---|
| Change from base Build 324: | 1.1% |
| Covered Lines: | 319 |
| Relevant Lines: | 365 |
💛 - Coveralls
Ebert has finished reviewing this Pull Request and has found:
- 1 possible new issue (including those that may have been commented here).
You can see more details about this review at https://ebertapp.io/github/ankhers/mongodb_ecto/pulls/171.
OK, I'm at a point when I think that it all works incorrectly 😭 I wrote a more complicated test case and tried to make it work:
https://github.com/ankhers/mongodb_ecto/blob/2d195a33e4c2519b51ba37d003e836a72a880194/test/mongo_ecto_test.exs#L94-L113
It uses these params:
{
3, # visits
4, 5, # not in visits
#BSON.ObjectId<5c4218d5ac013d8d6e5ecadc>, #BSON.ObjectId<5c4218d5ac013d8d6e5ecadd>, #BSON.ObjectId<5c4218d5ac013d8d6e5ecade>, # in ids
1, # offset
2 # limit
}
# ^ it could be much more simple it lists were not "flattened"
but generates this expression:
{:and, [],
[
{:and, [],
[
{:==, [],
[{{:., [], [{:&, [], [0]}, :visits]}, [], []}, {:^, [], [0]}]},
{:not, [],
[
{:in, [],
[{{:., [], [{:&, [], [0]}, :visits]}, [], []}, {:^, [], [1, 2]}]}
]}
]},
{:in, [], [{{:., [], [{:&, [], [0]}, :id]}, [], []}, {:^, [], [2, 3]}]}
# ^ why it starts with 2 for a list of [#BSON.ObjectId, #BSON.ObjectId, #BSON.ObjectId]
]}
cc @ankhers @michalmuskala