Skip to content

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

Description

@fidoman

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

Activity

  1. jwp commented on Feb 28, 2013

    @jwp
    Contributor

    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.

  2. commonism commented on Jul 4, 2014

    @commonism

    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.

  3. FirefighterBlu3 commented on Aug 4, 2014

    @FirefighterBlu3

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions