schema_plus 0.4.0 → 0.4.1

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.
data/README.rdoc CHANGED
@@ -176,6 +176,7 @@ take advantage of auto-creation of foreign keys, you can re-enable it:
176
176
  == History
177
177
 
178
178
  * Recent Release notes:
179
+ * 0.4.1 - bug fix: don't attempt foreign key creation for t.belongs_to ... :polymorphic => true
179
180
  * 0.4.0 - add :force for create_view (suggested by greglazarev[https://github.com/greglazarev]). cleanups by betelgeuse[https://github.com/betelgeuse]
180
181
  * 0.3.4 - bug fix: regression causing :default => false to be ignored
181
182
  * 0.3.3 - bug fix: properly handle boolean defaults in mysql
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/ronen/github/schema_plus
3
3
  specs:
4
- schema_plus (0.3.4)
4
+ schema_plus (0.4.0)
5
5
  rails
6
6
  valuable
7
7
 
@@ -19,7 +19,7 @@ GEM
19
19
  activesupport (= 2.3.14)
20
20
  activesupport (2.3.14)
21
21
  diff-lcs (1.1.3)
22
- multi_json (1.1.0)
22
+ multi_json (1.3.5)
23
23
  mysql (2.8.1)
24
24
  mysql2 (0.2.18)
25
25
  pg (0.13.2)
@@ -32,22 +32,22 @@ GEM
32
32
  activesupport (= 2.3.14)
33
33
  rake (>= 0.8.3)
34
34
  rake (0.8.7)
35
- rspec (2.9.0)
36
- rspec-core (~> 2.9.0)
37
- rspec-expectations (~> 2.9.0)
38
- rspec-mocks (~> 2.9.0)
39
- rspec-core (2.9.0)
40
- rspec-expectations (2.9.0)
35
+ rspec (2.10.0)
36
+ rspec-core (~> 2.10.0)
37
+ rspec-expectations (~> 2.10.0)
38
+ rspec-mocks (~> 2.10.0)
39
+ rspec-core (2.10.1)
40
+ rspec-expectations (2.10.0)
41
41
  diff-lcs (~> 1.1.3)
42
- rspec-mocks (2.9.0)
43
- simplecov (0.6.1)
42
+ rspec-mocks (2.10.1)
43
+ simplecov (0.6.4)
44
44
  multi_json (~> 1.0)
45
45
  simplecov-html (~> 0.5.3)
46
46
  simplecov-gem-adapter (1.0.1)
47
47
  simplecov
48
48
  simplecov-html (0.5.3)
49
- sqlite3 (1.3.5)
50
- valuable (0.9.3)
49
+ sqlite3 (1.3.6)
50
+ valuable (0.9.5)
51
51
 
52
52
  PLATFORMS
53
53
  ruby
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/ronen/github/schema_plus
3
3
  specs:
4
- schema_plus (0.3.4)
4
+ schema_plus (0.4.0)
5
5
  rails
6
6
  valuable
7
7
 
@@ -41,14 +41,14 @@ GEM
41
41
  erubis (2.6.6)
42
42
  abstract (>= 1.0.0)
43
43
  i18n (0.5.0)
44
- json (1.6.5)
44
+ json (1.7.3)
45
45
  mail (2.2.19)
46
46
  activesupport (>= 2.3.6)
47
47
  i18n (>= 0.4.0)
48
48
  mime-types (~> 1.16)
49
49
  treetop (~> 1.4.8)
50
- mime-types (1.17.2)
51
- multi_json (1.1.0)
50
+ mime-types (1.18)
51
+ multi_json (1.3.5)
52
52
  mysql (2.8.1)
53
53
  mysql2 (0.2.18)
54
54
  pg (0.13.2)
@@ -75,27 +75,27 @@ GEM
75
75
  rake (0.8.7)
76
76
  rdoc (3.12)
77
77
  json (~> 1.4)
78
- rspec (2.9.0)
79
- rspec-core (~> 2.9.0)
80
- rspec-expectations (~> 2.9.0)
81
- rspec-mocks (~> 2.9.0)
82
- rspec-core (2.9.0)
83
- rspec-expectations (2.9.0)
78
+ rspec (2.10.0)
79
+ rspec-core (~> 2.10.0)
80
+ rspec-expectations (~> 2.10.0)
81
+ rspec-mocks (~> 2.10.0)
82
+ rspec-core (2.10.1)
83
+ rspec-expectations (2.10.0)
84
84
  diff-lcs (~> 1.1.3)
85
- rspec-mocks (2.9.0)
86
- simplecov (0.6.1)
85
+ rspec-mocks (2.10.1)
86
+ simplecov (0.6.4)
87
87
  multi_json (~> 1.0)
88
88
  simplecov-html (~> 0.5.3)
89
89
  simplecov-gem-adapter (1.0.1)
90
90
  simplecov
91
91
  simplecov-html (0.5.3)
92
- sqlite3 (1.3.5)
92
+ sqlite3 (1.3.6)
93
93
  thor (0.14.6)
94
94
  treetop (1.4.10)
95
95
  polyglot
96
96
  polyglot (>= 0.3.1)
97
- tzinfo (0.3.32)
98
- valuable (0.9.3)
97
+ tzinfo (0.3.33)
98
+ valuable (0.9.5)
99
99
 
100
100
  PLATFORMS
101
101
  ruby
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/ronen/github/schema_plus
3
3
  specs:
4
- schema_plus (0.3.4)
4
+ schema_plus (0.4.0)
5
5
  rails
6
6
  valuable
7
7
 
@@ -42,13 +42,13 @@ GEM
42
42
  erubis (2.7.0)
43
43
  hike (1.2.1)
44
44
  i18n (0.6.0)
45
- json (1.6.5)
45
+ json (1.7.3)
46
46
  mail (2.3.3)
47
47
  i18n (>= 0.4.0)
48
48
  mime-types (~> 1.16)
49
49
  treetop (~> 1.4.8)
50
- mime-types (1.17.2)
51
- multi_json (1.1.0)
50
+ mime-types (1.18)
51
+ multi_json (1.3.5)
52
52
  mysql (2.8.1)
53
53
  mysql2 (0.3.11)
54
54
  pg (0.13.2)
@@ -80,32 +80,32 @@ GEM
80
80
  rake (0.8.7)
81
81
  rdoc (3.12)
82
82
  json (~> 1.4)
83
- rspec (2.9.0)
84
- rspec-core (~> 2.9.0)
85
- rspec-expectations (~> 2.9.0)
86
- rspec-mocks (~> 2.9.0)
87
- rspec-core (2.9.0)
88
- rspec-expectations (2.9.0)
83
+ rspec (2.10.0)
84
+ rspec-core (~> 2.10.0)
85
+ rspec-expectations (~> 2.10.0)
86
+ rspec-mocks (~> 2.10.0)
87
+ rspec-core (2.10.1)
88
+ rspec-expectations (2.10.0)
89
89
  diff-lcs (~> 1.1.3)
90
- rspec-mocks (2.9.0)
91
- simplecov (0.6.1)
90
+ rspec-mocks (2.10.1)
91
+ simplecov (0.6.4)
92
92
  multi_json (~> 1.0)
93
93
  simplecov-html (~> 0.5.3)
94
94
  simplecov-gem-adapter (1.0.1)
95
95
  simplecov
96
96
  simplecov-html (0.5.3)
97
- sprockets (2.0.3)
97
+ sprockets (2.0.4)
98
98
  hike (~> 1.2)
99
99
  rack (~> 1.0)
100
100
  tilt (~> 1.1, != 1.3.0)
101
- sqlite3 (1.3.5)
101
+ sqlite3 (1.3.6)
102
102
  thor (0.14.6)
103
103
  tilt (1.3.3)
104
104
  treetop (1.4.10)
105
105
  polyglot
106
106
  polyglot (>= 0.3.1)
107
- tzinfo (0.3.32)
108
- valuable (0.9.3)
107
+ tzinfo (0.3.33)
108
+ valuable (0.9.5)
109
109
 
110
110
  PLATFORMS
111
111
  ruby
@@ -1,38 +1,38 @@
1
1
  PATH
2
2
  remote: /Users/ronen/github/schema_plus
3
3
  specs:
4
- schema_plus (0.3.4)
4
+ schema_plus (0.4.0)
5
5
  rails
6
6
  valuable
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- actionmailer (3.2.2)
12
- actionpack (= 3.2.2)
13
- mail (~> 2.4.0)
14
- actionpack (3.2.2)
15
- activemodel (= 3.2.2)
16
- activesupport (= 3.2.2)
11
+ actionmailer (3.2.3)
12
+ actionpack (= 3.2.3)
13
+ mail (~> 2.4.4)
14
+ actionpack (3.2.3)
15
+ activemodel (= 3.2.3)
16
+ activesupport (= 3.2.3)
17
17
  builder (~> 3.0.0)
18
18
  erubis (~> 2.7.0)
19
19
  journey (~> 1.0.1)
20
20
  rack (~> 1.4.0)
21
- rack-cache (~> 1.1)
21
+ rack-cache (~> 1.2)
22
22
  rack-test (~> 0.6.1)
23
23
  sprockets (~> 2.1.2)
24
- activemodel (3.2.2)
25
- activesupport (= 3.2.2)
24
+ activemodel (3.2.3)
25
+ activesupport (= 3.2.3)
26
26
  builder (~> 3.0.0)
27
- activerecord (3.2.2)
28
- activemodel (= 3.2.2)
29
- activesupport (= 3.2.2)
27
+ activerecord (3.2.3)
28
+ activemodel (= 3.2.3)
29
+ activesupport (= 3.2.3)
30
30
  arel (~> 3.0.2)
31
31
  tzinfo (~> 0.3.29)
32
- activeresource (3.2.2)
33
- activemodel (= 3.2.2)
34
- activesupport (= 3.2.2)
35
- activesupport (3.2.2)
32
+ activeresource (3.2.3)
33
+ activemodel (= 3.2.3)
34
+ activesupport (= 3.2.3)
35
+ activesupport (3.2.3)
36
36
  i18n (~> 0.6)
37
37
  multi_json (~> 1.0)
38
38
  arel (3.0.2)
@@ -42,13 +42,13 @@ GEM
42
42
  hike (1.2.1)
43
43
  i18n (0.6.0)
44
44
  journey (1.0.3)
45
- json (1.6.5)
45
+ json (1.7.3)
46
46
  mail (2.4.4)
47
47
  i18n (>= 0.4.0)
48
48
  mime-types (~> 1.16)
49
49
  treetop (~> 1.4.8)
50
- mime-types (1.17.2)
51
- multi_json (1.1.0)
50
+ mime-types (1.18)
51
+ multi_json (1.3.5)
52
52
  mysql (2.8.1)
53
53
  mysql2 (0.3.11)
54
54
  pg (0.13.2)
@@ -60,17 +60,17 @@ GEM
60
60
  rack
61
61
  rack-test (0.6.1)
62
62
  rack (>= 1.0)
63
- rails (3.2.2)
64
- actionmailer (= 3.2.2)
65
- actionpack (= 3.2.2)
66
- activerecord (= 3.2.2)
67
- activeresource (= 3.2.2)
68
- activesupport (= 3.2.2)
63
+ rails (3.2.3)
64
+ actionmailer (= 3.2.3)
65
+ actionpack (= 3.2.3)
66
+ activerecord (= 3.2.3)
67
+ activeresource (= 3.2.3)
68
+ activesupport (= 3.2.3)
69
69
  bundler (~> 1.0)
70
- railties (= 3.2.2)
71
- railties (3.2.2)
72
- actionpack (= 3.2.2)
73
- activesupport (= 3.2.2)
70
+ railties (= 3.2.3)
71
+ railties (3.2.3)
72
+ actionpack (= 3.2.3)
73
+ activesupport (= 3.2.3)
74
74
  rack-ssl (~> 1.3.2)
75
75
  rake (>= 0.8.7)
76
76
  rdoc (~> 3.4)
@@ -78,32 +78,32 @@ GEM
78
78
  rake (0.8.7)
79
79
  rdoc (3.12)
80
80
  json (~> 1.4)
81
- rspec (2.9.0)
82
- rspec-core (~> 2.9.0)
83
- rspec-expectations (~> 2.9.0)
84
- rspec-mocks (~> 2.9.0)
85
- rspec-core (2.9.0)
86
- rspec-expectations (2.9.0)
81
+ rspec (2.10.0)
82
+ rspec-core (~> 2.10.0)
83
+ rspec-expectations (~> 2.10.0)
84
+ rspec-mocks (~> 2.10.0)
85
+ rspec-core (2.10.1)
86
+ rspec-expectations (2.10.0)
87
87
  diff-lcs (~> 1.1.3)
88
- rspec-mocks (2.9.0)
89
- simplecov (0.6.1)
88
+ rspec-mocks (2.10.1)
89
+ simplecov (0.6.4)
90
90
  multi_json (~> 1.0)
91
91
  simplecov-html (~> 0.5.3)
92
92
  simplecov-gem-adapter (1.0.1)
93
93
  simplecov
94
94
  simplecov-html (0.5.3)
95
- sprockets (2.1.2)
95
+ sprockets (2.1.3)
96
96
  hike (~> 1.2)
97
97
  rack (~> 1.0)
98
98
  tilt (~> 1.1, != 1.3.0)
99
- sqlite3 (1.3.5)
99
+ sqlite3 (1.3.6)
100
100
  thor (0.14.6)
101
101
  tilt (1.3.3)
102
102
  treetop (1.4.10)
103
103
  polyglot
104
104
  polyglot (>= 0.3.1)
105
- tzinfo (0.3.32)
106
- valuable (0.9.3)
105
+ tzinfo (0.3.33)
106
+ valuable (0.9.5)
107
107
 
108
108
  PLATFORMS
109
109
  ruby
@@ -53,8 +53,8 @@ module SchemaPlus::ActiveRecord::ConnectionAdapters
53
53
  # creation was disabled at initialization in the global Config.
54
54
  #
55
55
  # SchemaPlus likewise by default automatically creates foreign key constraints for
56
- # columns defined via <tt>t.references</tt>, unless the
57
- # <tt>:polymorphic</tt> option is true
56
+ # columns defined via <tt>t.references</tt>. However, SchemaPlus does not create
57
+ # foreign key constraints if the <tt>:polymorphic</tt> option is true
58
58
  #
59
59
  # Finally, the configuration for foreign keys can be overriden on a per-table
60
60
  # basis by passing Config options to Migration::ClassMethods#create_table, such as
@@ -75,6 +75,7 @@ module SchemaPlus::ActiveRecord::ConnectionAdapters
75
75
  alias_method_chain :initialize, :schema_plus
76
76
  alias_method_chain :column, :schema_plus
77
77
  alias_method_chain :references, :schema_plus
78
+ alias_method_chain :belongs_to, :schema_plus
78
79
  alias_method_chain :primary_key, :schema_plus
79
80
  alias_method_chain :to_sql, :schema_plus
80
81
  end
@@ -90,13 +91,24 @@ module SchemaPlus::ActiveRecord::ConnectionAdapters
90
91
  column(name, :primary_key, options)
91
92
  end
92
93
 
93
- def references_with_schema_plus(*args)
94
+ # need detect :polymorphic at this level, because rails strips it out
95
+ # before calling #column (twice, once for _id and once for _type)
96
+ def references_with_schema_plus(*args) #:nodoc:
94
97
  options = args.extract_options!
95
98
  options[:references] = nil if options[:polymorphic]
96
99
  args << options
97
100
  references_without_schema_plus(*args)
98
101
  end
99
102
 
103
+ # need detect :polymorphic at this level, because rails strips it out
104
+ # before calling #column (twice, once for _id and once for _type)
105
+ def belongs_to_with_schema_plus(*args) #:nodoc:
106
+ options = args.extract_options!
107
+ options[:references] = nil if options[:polymorphic]
108
+ args << options
109
+ belongs_to_without_schema_plus(*args)
110
+ end
111
+
100
112
  def column_with_schema_plus(name, type, options = {}) #:nodoc:
101
113
  column_without_schema_plus(name, type, options)
102
114
  schema_plus_handle_column_options(self.name, name, options, :config => schema_plus_config)
@@ -1,3 +1,3 @@
1
1
  module SchemaPlus
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -33,6 +33,11 @@ describe ActiveRecord::Migration do
33
33
  @model.should reference(:users, :id).on(:user_id)
34
34
  end
35
35
 
36
+ it "should not create foreign key using t.belongs_to with :polymorphic => true" do
37
+ create_table(@model, :user => {:METHOD => :belongs_to, :polymorphic => true})
38
+ @model.should_not reference(:users, :id).on(:user_id)
39
+ end
40
+
36
41
  it "should create foreign key using t.references" do
37
42
  create_table(@model, :user => {:METHOD => :references})
38
43
  @model.should reference(:users, :id).on(:user_id)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema_plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-05-09 00:00:00.000000000 Z
13
+ date: 2012-05-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
17
- requirement: &70249441590660 !ruby/object:Gem::Requirement
17
+ requirement: &70097168546520 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70249441590660
25
+ version_requirements: *70097168546520
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: valuable
28
- requirement: &70249441590200 !ruby/object:Gem::Requirement
28
+ requirement: &70097168546100 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70249441590200
36
+ version_requirements: *70097168546100
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: rake
39
- requirement: &70249441589680 !ruby/object:Gem::Requirement
39
+ requirement: &70097168545600 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 0.8.7
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *70249441589680
47
+ version_requirements: *70097168545600
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rspec
50
- requirement: &70249441589180 !ruby/object:Gem::Requirement
50
+ requirement: &70097168071980 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *70249441589180
58
+ version_requirements: *70097168071980
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: pg
61
- requirement: &70249441588700 !ruby/object:Gem::Requirement
61
+ requirement: &70097168069640 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: '0'
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *70249441588700
69
+ version_requirements: *70097168069640
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: mysql
72
- requirement: &70249441588240 !ruby/object:Gem::Requirement
72
+ requirement: &70097168068180 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: '0'
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *70249441588240
80
+ version_requirements: *70097168068180
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: sqlite3
83
- requirement: &70249441587820 !ruby/object:Gem::Requirement
83
+ requirement: &70097168067300 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ! '>='
@@ -88,10 +88,10 @@ dependencies:
88
88
  version: '0'
89
89
  type: :development
90
90
  prerelease: false
91
- version_requirements: *70249441587820
91
+ version_requirements: *70097168067300
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: simplecov
94
- requirement: &70249441587360 !ruby/object:Gem::Requirement
94
+ requirement: &70097168066460 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
97
  - - ! '>='
@@ -99,10 +99,10 @@ dependencies:
99
99
  version: '0'
100
100
  type: :development
101
101
  prerelease: false
102
- version_requirements: *70249441587360
102
+ version_requirements: *70097168066460
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: simplecov-gem-adapter
105
- requirement: &70249441586940 !ruby/object:Gem::Requirement
105
+ requirement: &70097168065260 !ruby/object:Gem::Requirement
106
106
  none: false
107
107
  requirements:
108
108
  - - ! '>='
@@ -110,7 +110,7 @@ dependencies:
110
110
  version: '0'
111
111
  type: :development
112
112
  prerelease: false
113
- version_requirements: *70249441586940
113
+ version_requirements: *70097168065260
114
114
  description: ! 'SchemaPlus is an ActiveRecord extension that provides enhanced capabilities
115
115
  for schema definition and querying, including: enhanced and more DRY index capabilities,
116
116
  support and automation for foreign key constraints, and support for views.'
@@ -236,3 +236,4 @@ test_files:
236
236
  - spec/support/matchers/reference.rb
237
237
  - spec/support/reference.rb
238
238
  - spec/views_spec.rb
239
+ has_rdoc: