composite_primary_keys 5.0.0 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,9 @@
1
+ == 5.0.1 2012-02-13
2
+ * Fix deprecation warning that was exactly backwards (Tom Hughes)
3
+ * Fix primary_keys handling in models that inherit from other models
4
+ but don't redefine their primary_key. Problem was the inherited
5
+ models didn't correctly reference their parents primary_keys (Charlie Savage)
6
+
1
7
  == 5.0.0 2012-02-12
2
8
  * Fix tests so they pass on MySql (Charlie Savage)
3
9
  * Fix calculations to work with duplicate column names (cleesmith)
@@ -8,9 +8,19 @@ module ActiveRecord
8
8
 
9
9
  class << self
10
10
  def primary_keys
11
+ unless defined?(@primary_keys)
12
+ reset_primary_keys
13
+ end
11
14
  @primary_keys
12
15
  end
13
16
 
17
+ # Don't like this method name, but its modeled after how AR does it
18
+ def reset_primary_keys
19
+ if self != base_class
20
+ self.primary_keys = base_class.primary_keys
21
+ end
22
+ end
23
+
14
24
  def primary_keys=(keys)
15
25
  unless keys.kind_of?(Array)
16
26
  self.primary_key = keys
@@ -27,7 +37,7 @@ module ActiveRecord
27
37
 
28
38
  def set_primary_keys(*keys)
29
39
  ActiveSupport::Deprecation.warn(
30
- "Calling self.primary_keys = is deprecated. Please use `self.primary_keys = keys` instead."
40
+ "Calling set_primary_keys is deprecated. Please use `self.primary_keys = keys` instead."
31
41
  )
32
42
 
33
43
  keys = keys.first if keys.first.is_a?(Array)
@@ -140,4 +150,4 @@ module ActiveRecord
140
150
  end
141
151
  end
142
152
  end
143
- end
153
+ end
@@ -2,7 +2,7 @@ module CompositePrimaryKeys
2
2
  module VERSION
3
3
  MAJOR = 5
4
4
  MINOR = 0
5
- TINY = 0
5
+ TINY = 1
6
6
  STRING = [MAJOR, MINOR, TINY].join('.')
7
7
  end
8
8
  end
@@ -1,5 +1,8 @@
1
1
  require File.expand_path('../abstract_unit', __FILE__)
2
2
 
3
+ class ChildCpkTest < ReferenceCode
4
+ end
5
+
3
6
  class TestIds < ActiveSupport::TestCase
4
7
  fixtures :reference_types, :reference_codes
5
8
 
@@ -81,6 +84,15 @@ class TestIds < ActiveSupport::TestCase
81
84
  end
82
85
  end
83
86
 
87
+ def test_inherited_primary_keys
88
+ assert_equal([:reference_type_id, :reference_code], ChildCpkTest.primary_keys)
89
+ end
90
+
91
+ def test_inherited_ids
92
+ cpk_test = ChildCpkTest.new
93
+ assert_equal([nil, nil], cpk_test.id)
94
+ end
95
+
84
96
  def test_assign_ids
85
97
  ref_code = ReferenceCode.new
86
98
  assert_equal([nil, nil], ref_code.id)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: composite_primary_keys
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.0.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-02-12 00:00:00.000000000 Z
13
+ date: 2012-02-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
17
- requirement: &24424140 !ruby/object:Gem::Requirement
17
+ requirement: &21857400 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,7 +22,7 @@ dependencies:
22
22
  version: 3.2.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *24424140
25
+ version_requirements: *21857400
26
26
  description: Composite key support for ActiveRecord
27
27
  email:
28
28
  executables: []
@@ -192,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
192
  version: '0'
193
193
  requirements: []
194
194
  rubyforge_project: compositekeys
195
- rubygems_version: 1.8.15
195
+ rubygems_version: 1.8.16
196
196
  signing_key:
197
197
  specification_version: 3
198
198
  summary: Composite key support for ActiveRecord