postgres_ext 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -82,6 +82,8 @@ module ActiveRecord
82
82
 
83
83
  def simplified_type_with_extended_types(field_type)
84
84
  case field_type
85
+ when 'uuid'
86
+ :uuid
85
87
  when 'inet'
86
88
  :inet
87
89
  when 'cidr'
@@ -89,7 +91,6 @@ module ActiveRecord
89
91
  when 'macaddr'
90
92
  :macaddr
91
93
  when /(\[\])$/
92
- debugger
93
94
  "#{simplified_type field_type[0..field_type.length - 3]}_array".to_sym
94
95
  else
95
96
  simplified_type_without_extended_types field_type
@@ -100,7 +101,7 @@ module ActiveRecord
100
101
  end
101
102
 
102
103
  class PostgreSQLAdapter
103
- EXTENDED_TYPES = {:inet => {:name => 'inet'}, :cidr => {:name => 'cidr'}, :macaddr => {:name => 'macaddr'}}
104
+ EXTENDED_TYPES = {:inet => {:name => 'inet'}, :cidr => {:name => 'cidr'}, :macaddr => {:name => 'macaddr'}, :uuid => {:name => 'uuid'}}
104
105
  class ColumnDefinition < ActiveRecord::ConnectionAdapters::ColumnDefinition
105
106
  attr_accessor :array
106
107
  end
@@ -1,3 +1,3 @@
1
1
  module PostgresExt
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'UUID migrations' do
4
+ let!(:connection) { ActiveRecord::Base.connection }
5
+ it 'creates an uuid column' do
6
+ lambda do
7
+ connection.create_table :data_types do |t|
8
+ t.uuid :cidr_1
9
+ t.uuid :cidr_2, :cidr_3
10
+ t.column :cidr_4, :uuid
11
+ end
12
+ end.should_not raise_exception
13
+
14
+ columns = connection.columns(:data_types)
15
+ cidr_1 = columns.detect { |c| c.name == 'cidr_1'}
16
+ cidr_2 = columns.detect { |c| c.name == 'cidr_2'}
17
+ cidr_3 = columns.detect { |c| c.name == 'cidr_3'}
18
+ cidr_4 = columns.detect { |c| c.name == 'cidr_4'}
19
+
20
+ cidr_1.sql_type.should eq 'uuid'
21
+ cidr_2.sql_type.should eq 'uuid'
22
+ cidr_3.sql_type.should eq 'uuid'
23
+ cidr_4.sql_type.should eq 'uuid'
24
+ end
25
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'UUID schema dump' do
4
+ let!(:connection) { ActiveRecord::Base.connection }
5
+ it 'correctly generates uuid column statements' do
6
+ stream = StringIO.new
7
+ connection.create_table :testings do |t|
8
+ t.uuid :network_column
9
+ end
10
+
11
+ ActiveRecord::SchemaDumper.dump(connection, stream)
12
+ output = stream.string
13
+
14
+ output.should match /t\.uuid/
15
+ end
16
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postgres_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-11 00:00:00.000000000 Z
12
+ date: 2012-06-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -239,10 +239,12 @@ files:
239
239
  - spec/migrations/cidr_spec.rb
240
240
  - spec/migrations/inet_spec.rb
241
241
  - spec/migrations/macaddr_spec.rb
242
+ - spec/migrations/uuid_spec.rb
242
243
  - spec/schema_dumper/array_spec.rb
243
244
  - spec/schema_dumper/cidr_spec.rb
244
245
  - spec/schema_dumper/inet_spec.rb
245
246
  - spec/schema_dumper/macaddr_spec.rb
247
+ - spec/schema_dumper/uuid_spec.rb
246
248
  - spec/spec_helper.rb
247
249
  homepage: ''
248
250
  licenses: []
@@ -258,7 +260,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
258
260
  version: '0'
259
261
  segments:
260
262
  - 0
261
- hash: 481070527403987140
263
+ hash: -161966388102322478
262
264
  required_rubygems_version: !ruby/object:Gem::Requirement
263
265
  none: false
264
266
  requirements:
@@ -267,7 +269,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
267
269
  version: '0'
268
270
  segments:
269
271
  - 0
270
- hash: 481070527403987140
272
+ hash: -161966388102322478
271
273
  requirements: []
272
274
  rubyforge_project:
273
275
  rubygems_version: 1.8.23
@@ -332,8 +334,10 @@ test_files:
332
334
  - spec/migrations/cidr_spec.rb
333
335
  - spec/migrations/inet_spec.rb
334
336
  - spec/migrations/macaddr_spec.rb
337
+ - spec/migrations/uuid_spec.rb
335
338
  - spec/schema_dumper/array_spec.rb
336
339
  - spec/schema_dumper/cidr_spec.rb
337
340
  - spec/schema_dumper/inet_spec.rb
338
341
  - spec/schema_dumper/macaddr_spec.rb
342
+ - spec/schema_dumper/uuid_spec.rb
339
343
  - spec/spec_helper.rb