Skip to content
This repository has been archived by the owner on Sep 2, 2019. It is now read-only.

DM self-referential associations not working #23

Open
disbelief opened this issue Nov 30, 2011 · 2 comments
Open

DM self-referential associations not working #23

disbelief opened this issue Nov 30, 2011 · 2 comments
Assignees

Comments

@disbelief
Copy link

Please excuse me if this is actually not a problem as I am a bit new to both DataMapper and Redis. However I am following the example code in the DataMapper Associations documentation (http://datamapper.org/docs/associations.html) for creating a Twitter-like follower + followed self-referential association in my User model.

This pastie should illustrate the problem: http://pastie.org/2943832

As you can see, when the association is first created, user1 ends up following himself along with the user he was intended to follow, user2 believes she has one follower, but can't seem to find any links_to_followers. Furthermore, unfollowing seems to leave an orphan association on the followed user's side of the association, and just generally seems to make a mess of things.

It seems that the association isn't being stored in/queried from Redis properly, or perhaps it simply isn't possible to store such a relationship in Redis?

@ghost ghost assigned whoahbot Nov 30, 2011
@whoahbot
Copy link
Owner

whoahbot commented Dec 1, 2011

Hello disbelief!

It is possible to store this relationship in redis, but it looks to me as though the adapter isn't handling the join model correctly. I'll have a closer look at this and let you know what I find.

@disbelief
Copy link
Author

Thanks Dan!

In the meantime, I've implemented my user graph directly via Redis commands, more or less as described in this Redis Cookbook recipe: http://rediscookbook.org/implement_a_social_graph.html

However I would obviously prefer to do it the DM way, so I'm looking forward to what you come up with.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants