-
Notifications
You must be signed in to change notification settings - Fork 80
DataMapper::Property::IPAddress attempts to typecase LIKE-queries #53
Comments
I'm thinking that maybe we need to add a |
@dkubb Just being a noob here, where does the magic with that comparison happen? 2 cents: Ruby's IPAddr is pretty weak, and doesn't easily allow for important comparisons, like seeing if an IP is in a subnet, getting the subnet mask back from the object after it's set, or other interesting things that ipaddr_extensions and ruby-ip provide. Also, serialization to integer seems to make some more sense than a string. I would suppose the point of an IP type is getting an IPAddr object back. Is it a bug that you can't compare unlike classes? |
@skord I've written a crude NumericIPAddr Property before. A formal one should probably be added to dm-types, that also packs the netmask as an extra byte. I'm curious if we could mimic the underlying format that MySQL / PostgreSQL uses for native IPs. |
@skord Although switching to a numeric format would make supporting |
Packing the extra byte? Not thinking about that so much as the efficiency gained from numerical storage and indexing. It's especially apparent when you need to query for all the IP's in a supernet, which may outweigh a text like query when crossing obvious classful subnets. The crux of the issue is deep. |
I discovered that the IPAddress property will attempt to typecast the values used in
.like
queries, which results in anArgumentError
being raised byIPAddr.new
.Reproduction: https://github.com/postmodern/dm-bug-report/tree/ip_address_typecast
Reproduced on 1.1.0, 1.2.0 and Edge.
The text was updated successfully, but these errors were encountered: