So it looks like [7151] broke exact lookups for IP types in
PostgreSQL; this now fails::
>>> Model.objects.create(ip="10.0.0.1")
>>> Model.objects.get(ip="10.0.0.1")
You can see this in action in the failing serializers_regress unit
test (http://buildbot.djangoproject.com/trunk%202.5%20psycopg2/builds/338/step-test/0).
The problem is the casting -- ``CAST(ip AS text)`` returns something
of the form "10.0.0.1/32" (i.e. ip/netmask), which (obviously) doesn't
match the more simple IP.
Thus I'd like to revert [7151] until we can figure out a better fix
for substring searches. Any objections?
Jacob
Whoops, my bad. Could have sworn I ran all the tests before committing.
Sorry about that. :-(
Definitely revert it. As noted in the ticket, I'm not 100% happy with
the solution anyway, for efficiency reasons, but this confirms that
doing the cast always is stupid.
We need to come up with a better solution for this stuff in general as
it comes up in a different form in #6605. I'm leaning towards doing a
cast based on both field type and lookup type for #6605. I think that
probably solves this problem as well: we only do the cast for the
particular lookup types (contains, icontains, etc).
Malcolm
--
Why can't you be a non-conformist like everyone else?
http://www.pointy-stick.com/blog/
On Tue, Feb 26, 2008 at 03:08:57PM -0600, Jacob Kaplan-Moss wrote:
> The problem is the casting -- ``CAST(ip AS text)`` returns something
> of the form "10.0.0.1/32" (i.e. ip/netmask), which (obviously) doesn't
> match the more simple IP.
Like you said you don't want to use ``CAST(ip AS text)`` here, try using
``host(ip)`` and you should get the desired result.
http://www.postgresql.org/docs/8.2/static/functions-net.html has å nice
overview of the net related functions in PG :)
-Thomas
--
Thomas Kongevold Adamcik
That's not really related to the issue at hand. It's overkill to have to
inspect a "contains" lookup to see if it's possible a host address and
then use host(ip), otherwise cast to a string for string-style lookups.
Anything that requires that level of deep introspection isn't really
practical via the standard lookups.
Malcolm
--
Monday is an awful way to spend 1/7th of your life.
http://www.pointy-stick.com/blog/
Nope, I'm an idiot (again). You are correct.
Malcolm
--
Quantum mechanics: the dreams stuff is made of.
http://www.pointy-stick.com/blog/
Ah, that's it -- thanks! Committed in [7161].
Jacob