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

inet type looks different when inserted through variable or as part of query text #66

Open
fidoman opened this issue Feb 28, 2013 · 3 comments

Comments

@fidoman
Copy link

fidoman commented Feb 28, 2013

c.prepare("insert into test_ip (addr) values ('10.0.0.1')")() - saves to table '10.0.0.1'
c.prepare("insert into test_ip (addr) values ($1)")("10.0.0.1") - saves to table '10.0.0.1/0'

When queried with the python-postgres both values looks identical - IPv4Address('10.0.0.1')
but other apps get confused.

Tried with postgres 9.1.3 and 9.1.8, python 3.3 and library 1.1.0

@jwp
Copy link
Contributor

jwp commented Feb 28, 2013

hmm, guess PG's binary representation allows us to store unexpected inet values. Arguably, this is both a py-postgresql and a postgresql bug as inet instances aren't supposed to have masks AFAIK. This should be an easy fix.

@commonism
Copy link

http://www.postgresql.org/docs/9.3/static/datatype-net-types.html
8.9.3. inet vs. cidr
The essential difference between inet and cidr data types is that inet accepts values with nonzero bits to the right of the netmask, whereas cidr does not.

I'd be pleased if this could be fixed, as this bug breaks the INET type.
Reverting the changes to use ipaddress or using ipaddress.ip_interface are valid options.

@FirefighterBlu3
Copy link

i made a patch that corrects this unexpected behavior in #71 as @commonism refers to

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

No branches or pull requests

4 participants