Support postgres CIDR type

Issue #1092 resolved
Former user created an issue

I've noticed that you don't have support for the postgres CIDR type. AFAICT, a CIDR mainly differs from an INET in what is a valid value. It checks to see that anything that is a zero in the netmask is a zero in the address (ie. 192.168.0.1/16 would be a valid INET, but invalid CIDR).

Here is a patch against 0.4.6 .

--- sqlalchemy/databases/postgres.py 2008-07-01 10:13:02.000000000 -0600 +++ sqlalchemy/databases/postgres.py 2008-07-01 10:14:10.000000000 -0600 @@ -32,6 +32,10 @@ def get_col_spec(self): return "INET"

+class PGCidr(sqltypes.TypeEngine): + def get_col_spec(self): + return "CIDR" + class PGMacAddr(sqltypes.TypeEngine): def get_col_spec(self): return "MACADDR" @@ -200,6 +204,7 @@ 'float' : PGFloat, 'real' : PGFloat, 'inet': PGInet, + 'cidr': PGCidr, 'macaddr': PGMacAddr, 'double precision' : PGFloat, 'timestamp' : PGDateTime,

Comments (4)

  1. Log in to comment