You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 18, 2020. It is now read-only.
If I have two schemas that are related through a many_to_many relationship using a Join schema, I do not get the expected number of results (I get too few values) when I query the database with rethinkdb_ecto to retrieve all items associated with one item of the other schema.
I have verified that the join schema table itself contains the right data, and queries to rethinkdb directly using eqJoin give the expected number of results.
I'm using phoenix 1.3.0, elixir 1.5.1, erlang/OTP 20 on Archlinux with rethinkdb 2.3.6.
Now I put 150 items in :posts, all of which are associated with, say, one item in :tags like so:
# Insert 150 Postsposts=1..150|>Enum.map(fn_->Post.changeset(%Post{},%{title: "Some Title",content: "This is a sentence"})|>Repo.insert!end)# Insert 1 tagtag=Tag.changeset(%Tag{},%{name: "Shakespeare"})|>Repo.insert!# Insert associations between all the posts and the one tagEnum.map(posts,fnpost->PostTag.changeset(%PostTag{},%{post_id: post.id,tag_id: tag.id})|>Repo.insert!end)
Now, when I try to retrieve all the posts associated with the tag:
tag = hd Repo.all(Tag)
posts = Repo.all(assoc(tag, :posts))
I do not get back 150 posts as expected, but much fewer. In fact the exact number of posts I get back varies from time to time, and is around 40-50.
The text was updated successfully, but these errors were encountered:
I did investigate a little bit on this and found out that many_to_many require more complex handling of joins via the adapter. Don't have time to fix this right now but any help is welcome.
In the meantime, you might want to stick to has_many or embeds_many.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Issue
If I have two schemas that are related through a
many_to_many
relationship using a Join schema, I do not get the expected number of results (I get too few values) when I query the database withrethinkdb_ecto
to retrieve all items associated with one item of the other schema.I have verified that the join schema table itself contains the right data, and queries to rethinkdb directly using
eqJoin
give the expected number of results.I'm using phoenix 1.3.0, elixir 1.5.1, erlang/OTP 20 on Archlinux with rethinkdb 2.3.6.
Detailed steps to reproduce
I have two schemas like so:
which have a many-to-many mapping between each other using an intermediate schema (like in the official example:
Now I put 150 items in
:posts
, all of which are associated with, say, one item in:tags
like so:Now, when I try to retrieve all the posts associated with the tag:
I do not get back 150 posts as expected, but much fewer. In fact the exact number of posts I get back varies from time to time, and is around 40-50.
The text was updated successfully, but these errors were encountered: