-
Notifications
You must be signed in to change notification settings - Fork 877
Description
Npgsql currently PG cidr to .NET ValueTuple<IPAddress, int> by default, and also allows mapping inet to it. There's also an obsolete NpgsqlInet mutable struct. For 8.0, we'll do the following changes:
- We'll un-obsolete NpgsqlInet, make it an immutable struct and clean it up.
- IPAddress will remain the default mapping for
inet, as that's what most users use it for. - Note that as before, reading an
inetwith a non-full netmask silently truncates the value. This seems reasonable as the primary usage ofinetis to store simple host IPs (i.e. IPAddress). If the netmask component is significant, NpgsqlInet mapping can be used instead.
- IPAddress will remain the default mapping for
- We'll also introduce a similar immutable NpgsqlCidr struct, and remove the value tuple mapping.
- NpgsqlCidr will be the default mapping for
cidr, as that type is used to represent networks, where both the IP and netmask components are important. - The ValueTuple mapping will be removed.
Some notes on why it makes sense to have separate NpgsqlInet and NpgsqlCidr types for PG inet and cidr:
inetcan represent a single IP Address, and so should be constructible/castable from one; that's not the case forcidr.inetToString doesn't output the netmask if it has all bits (32 for IPv4/128 for IPv6). This doesn't really make sense forcidr.- Having a separate CLR type for
cidrwould allow mapping it by default without requiring explicit specification of NpgsqlDbType/DataTypeName.
Reactions are currently unavailable