Add support for macaddr, inet, and cidr types to PostgreSQL adapter #6192

Merged
merged 3 commits into from May 16, 2012

Conversation

Projects
None yet
5 participants
Contributor

danmcclain commented May 7, 2012

Adds migration and schema dump support for macaddr, inet and cidr column types in the PostgreSQL adapter.

Converst inet and cidr types to NetAddr::CIDR objects, instead of using IPAddr, since NetAddr::CIDR handles subnets better.

activerecord/activerecord.gemspec
@@ -24,4 +24,5 @@ Gem::Specification.new do |s|
s.add_dependency('arel', '~> 3.0.2')
s.add_dependency('active_record_deprecated_finders', '0.0.1')
+ s.add_dependency('netaddr', '~> 1.5.0')
@rafaelfranca

rafaelfranca May 7, 2012

Owner

I think that we should not add netaddr gem as Active Record dependency because we will only use it with PostgreSQL.

@danmcclain

danmcclain May 7, 2012

Contributor

This is the one issue I thought the pull request would definitely have. I was unsure of how to make netaddr a PostgreSQL only dependency

@danmcclain

danmcclain May 7, 2012

Contributor

I am going to update this so that it will try to use NetAddr if the user has included it, if not, it will fall back to IPAddr.

@tenderlove

tenderlove May 16, 2012

Owner

I'll fix it. We should just do a gem netaddr in the pg adapter code.

Contributor

danmcclain commented May 8, 2012

I have updated my implementation to remove NetAddr completely, after discovering how to extract the subnet mask from IPAddr

Contributor

danmcclain commented May 8, 2012

Contributor

jeremyf commented May 9, 2012

The tests all pass. I'm not familiar with the adapters, but am wondering if there is a way to push the Gemfile requirements onto the Postgres adapter gem (I'm assuming there's such a thing as Postgres adapter gem).

@tenderlove can you review?

Owner

rafaelfranca commented May 9, 2012

@danmcclain looks great now.

@jeremyf the only way to push requirements to the PostgreSQL adapter is adding as requirement of the pg gem or other PostgreSQL gem.

Contributor

bcardarella commented May 15, 2012

this looks pretty good, 👍 on merge

tenderlove added a commit that referenced this pull request May 16, 2012

Merge pull request #6192 from danmcclain/add_inet_and_cidr_types_to_p…
…ostgresql_adapter

Add support for macaddr, inet, and cidr types to PostgreSQL adapter

@tenderlove tenderlove merged commit 835df6f into rails:master May 16, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment