Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Equality (==) on Models #61

Open
christopher-dG opened this issue Apr 5, 2017 · 1 comment
Open

Implement Equality (==) on Models #61

christopher-dG opened this issue Apr 5, 2017 · 1 comment

Comments

@christopher-dG
Copy link
Contributor

Last thing I'll bug you with for a while!

I have a comment child, and that comment is the only reply to another comment parent.

reply = parent.reload.replies[0]
reply.body == child.body  # => true
reply.id == child.id  # => true
reply == child  # => false

I don't think that you can uniquely identify a comment with just its ID, but if you can get the post ID that they each replied to, then you could compare reply.id == child.id && reply.subreddit.id == child.subreddit.id && post_id == child.post_id (this already works for link posts with link_id but I'm not sure if an equivalent exists for self posts.

@avinashbot avinashbot changed the title c1 == c2 on identical(?) comments returns false Implement Equality (==) on Models Apr 5, 2017
@avinashbot
Copy link
Owner

Actually, you can indeed just compare ids. Comments have unique ids, so as long as you're not comparing Submission IDs with Comment IDs, id should be fine. Leaving this one open as well, can't believe I haven't implemented this!

@avinashbot avinashbot added the bug label Apr 5, 2017
@avinashbot avinashbot added this to the v0.8.9 milestone Aug 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants