Skip to content

in causing query to be order dependent #134

Open
@ankhers

Description

@ankhers

I will admit that I am not 100% that in is causing this issue, I have not dug deep enough into it.

MyApp.Repo.all(from l in MyApp.Location,
  where: l.id in ^location_ids and l.company_id == ^company.id)

The following is the output from the logger from the query

FIND coll="locations" query=[{"$query", ["$and": [[_id: ["$in": [#BSON.ObjectId<578cda4955cf0a1638000001>, #BSON.ObjectId<54bd44f0946002b22a000528>, #BSON.ObjectId<58125b8e8a97fa9ce4000004>, #BSON.ObjectId<5787d39855cf0afc62000003>, #BSON.ObjectId<528b91bdf1f179db9400065c>, #BSON.ObjectId<57868f1a94600275a30001d3>, #BSON.ObjectId<55fc097694600262be001f15>, #BSON.ObjectId<58125a7b5f8524c2b800000b>, #BSON.ObjectId<5476227655cf0a12fc00006c>]]], [company_id: #BSON.ObjectId<54bd44f0946002b22a000528>]]]}, {"$orderby", %{}}] projection=%{...} []

The following is the "modified" working query

MyApp.Repo.all(from l in MyApp.Location,
  where: l.company_id == ^company.id and l.id in ^location_ids)

The following is the output of the working query

FIND coll="locations" query=[{"$query", ["$and": [[company_id: #BSON.ObjectId<5283c9b5f1f179b3d5000cba>], [_id: ["$in": [#BSON.ObjectId<578cda4955cf0a1638000001>, #BSON.ObjectId<54bd44f0946002b22a000528>, #BSON.ObjectId<58125b8e8a97fa9ce4000004>, #BSON.ObjectId<5787d39855cf0afc62000003>, #BSON.ObjectId<528b91bdf1f179db9400065c>, #BSON.ObjectId<57868f1a94600275a30001d3>, #BSON.ObjectId<55fc097694600262be001f15>, #BSON.ObjectId<58125a7b5f8524c2b800000b>, #BSON.ObjectId<5476227655cf0a12fc00006c>]]]]]}, {"$orderby", %{}}] projection=%{...} []

The key part here to note is that for some reason the company_id changed between the two queries. I promise I used the same information for both queries. I feel like this is related to #104.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions