composite_primary_keys 1.0.6 → 1.0.7
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/History.txt +5 -1
- data/lib/composite_primary_keys/associations.rb +5 -4
- data/lib/composite_primary_keys/version.rb +1 -1
- data/test/test_create.rb +8 -1
- data/tmp/test.db +0 -0
- data/website/index.html +1 -1
- data/website/version-raw.js +1 -1
- data/website/version.js +1 -1
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
== 1.0.7 2008-08-12
|
2
|
+
|
3
|
+
* fix for the last fix -- when has_many is composite and belongs_to is single
|
4
|
+
|
1
5
|
== 1.0.6 2008-08-06
|
2
6
|
|
3
7
|
* fix associations create
|
@@ -123,4 +127,4 @@
|
|
123
127
|
* id sets: Foo.find(2,1),
|
124
128
|
* lists of id sets: Foo.find([2,1], [7,3], [8,12]),
|
125
129
|
* and even stringified versions of the above:
|
126
|
-
* Foo.find '2,1' or Foo.find '2,1;7,3'
|
130
|
+
* Foo.find '2,1' or Foo.find '2,1;7,3'
|
@@ -281,14 +281,15 @@ module ActiveRecord::Associations
|
|
281
281
|
keys_ids = [keys, quoted_ids].transpose
|
282
282
|
keys_ids.collect {|key, id| "(#{table_name}.#{key} = #{id})"}.join(' AND ')
|
283
283
|
end
|
284
|
-
|
284
|
+
|
285
285
|
def set_belongs_to_association_for(record)
|
286
286
|
if @reflection.options[:as]
|
287
|
-
|
287
|
+
record["#{@reflection.options[:as]}_id"] = @owner.id unless @owner.new_record?
|
288
|
+
record["#{@reflection.options[:as]}_type"] = @owner.class.base_class.name.to_s
|
288
289
|
else
|
289
|
-
key_values = @reflection.primary_key_name.to_s.split(CompositePrimaryKeys::ID_SEP).zip(@owner.id)
|
290
|
+
key_values = @reflection.primary_key_name.to_s.split(CompositePrimaryKeys::ID_SEP).zip([@owner.id].flatten)
|
290
291
|
key_values.each{|kv| record[kv.first] = kv.last} unless @owner.new_record?
|
291
|
-
end
|
292
|
+
end
|
292
293
|
end
|
293
294
|
end
|
294
295
|
|
data/test/test_create.rb
CHANGED
@@ -58,4 +58,11 @@ class TestCreate < Test::Unit::TestCase
|
|
58
58
|
assert_equal(suburb.city_id, street.city_id)
|
59
59
|
assert_equal(suburb.suburb_id, street.suburb_id)
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
|
+
def test_create_on_association_when_belongs_to_is_single_key
|
63
|
+
rt = ReferenceType.find(:first)
|
64
|
+
rt.reference_codes.create(:reference_type_id => 1234, :reference_code => 4321, :code_label => 'foo', :abbreviation => 'bar')
|
65
|
+
rc = ReferenceCode.find_by_reference_code(4321)
|
66
|
+
assert_equal(rc.reference_type_id, rt.reference_type_id)
|
67
|
+
end
|
68
|
+
end
|
data/tmp/test.db
CHANGED
Binary file
|
data/website/index.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>Composite Primary Keys</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/compositekeys"; return false'>
|
35
35
|
Get Version
|
36
|
-
<a href="http://rubyforge.org/projects/compositekeys" class="numbers">1.0.
|
36
|
+
<a href="http://rubyforge.org/projects/compositekeys" class="numbers">1.0.6</a>
|
37
37
|
</div>
|
38
38
|
<h1>→ Ruby on Rails</h1>
|
39
39
|
|
data/website/version-raw.js
CHANGED
data/website/version.js
CHANGED
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: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dr Nic Williams
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-08-
|
12
|
+
date: 2008-08-12 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|