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

correct handling of __eq__ comparison of ranges with non-ranges #5

Merged
merged 3 commits into from
Jun 18, 2013

Conversation

cjw296
Copy link
Contributor

@cjw296 cjw296 commented May 26, 2013

I originally thought a more useful error message was all that's needed, but it turns out that raising any exception here causes problems with SQLAlchemy's internal state tracking.

@cjw296
Copy link
Contributor Author

cjw296 commented May 26, 2013

Hmm, or maybe it should just "return False", which actually works where I hit this better than the TypeError above.

What are your thoughts?

@dvarrazzo
Copy link
Member

I think returning false is a better option, yes:

In [1]: print 1 == 'a'
False

Also, checking self.class is probably too strict (or just wrong) w.r.t. subclassing: think e.g. (just making up) if there is a IntRange subclassed in a PositiveIntRange I think your implementation would give different values checking ir == pir and pir == ir. So I think the check should be if not isinstance(other, Range):.

@dvarrazzo
Copy link
Member

That looks cool, thank you. Will merge soon-ish.

dvarrazzo added a commit that referenced this pull request Jun 18, 2013
Not an original psycopg2 bug but present in pure python implementation,
e.g. ctypes issue #25 and cffi issue #5.

mvantellingen/psycopg2-ctypes#25
chtd/psycopg2cffi#5
dvarrazzo added a commit that referenced this pull request Jun 18, 2013
Not an original psycopg2 bug but present in pure python implementation,
e.g. ctypes issue #25 and cffi issue #5.

mvantellingen/psycopg2-ctypes#25
chtd/psycopg2cffi#5
@dvarrazzo dvarrazzo merged commit 28276e3 into psycopg:master Jun 18, 2013
@cjw296 cjw296 deleted the range_eq_typerror branch June 18, 2013 13:48
dvarrazzo added a commit that referenced this pull request May 5, 2014
Not an original psycopg2 bug but present in pure python implementation,
e.g. ctypes issue #25 and cffi issue #5.

mvantellingen/psycopg2-ctypes#25
chtd/psycopg2cffi#5
@dvarrazzo dvarrazzo mentioned this pull request Jun 18, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants