composite_primary_keys 7.0.0 → 7.0.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.
- checksums.yaml +4 -4
- data/History.rdoc +14 -0
- data/README.rdoc +1 -3
- data/lib/composite_primary_keys.rb +0 -2
- data/lib/composite_primary_keys/base.rb +0 -1
- data/lib/composite_primary_keys/persistence.rb +0 -10
- data/lib/composite_primary_keys/version.rb +1 -1
- metadata +1 -2
- data/lib/composite_primary_keys/active_record_overides.rb +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67949f62c5795509a482f74ac109193f0d6e294a
|
4
|
+
data.tar.gz: 1705dca290c512bd57401db0d61cc58e2c13d6d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebead783540875cd89cfefce57b3113b85d76295753d4029f54c5b866598a6a5961d1f0bb247fff7279716b1e9989bea4607c1be247e884b662ec934adcd08ef
|
7
|
+
data.tar.gz: 563cf8163a7526483b14018b4438134c7ca4cbac0b1868003d864d7f55348f61e686c472afed787db5ef8aed0377ee886a09d7167caf3a8623025ef21b106532
|
data/History.rdoc
CHANGED
@@ -1,7 +1,21 @@
|
|
1
|
+
== 7.0.1 (2014-05-27)
|
2
|
+
|
3
|
+
* Fix setting of timestamps automatically by Rails (Charlie Savage)
|
4
|
+
|
1
5
|
== 7.0.0 (2014-05-26)
|
2
6
|
|
3
7
|
* Active Record 4.1 support! (Charlie Savage, Tom Hughes, Simon South)
|
4
8
|
|
9
|
+
Note there is one big api change. Previously, CPK supported both of these calls:
|
10
|
+
|
11
|
+
Membership.find(1,1)
|
12
|
+
Membership.find([1,1])
|
13
|
+
|
14
|
+
The first one no longer works. It was removed because it made the internal code simpler
|
15
|
+
and makes the intention of the code clearer (especially when finding multiple records).
|
16
|
+
If this change causes too much pain then please submit a ticket on Github.
|
17
|
+
|
18
|
+
|
5
19
|
== 6.0.6 (2014-05-26)
|
6
20
|
|
7
21
|
* Don't refer to deprecated set_primary_keys in README (Henare Degan)
|
data/README.rdoc
CHANGED
@@ -88,9 +88,7 @@ See test/README_tests.rdoc
|
|
88
88
|
|
89
89
|
== Questions, Discussion and Contributions
|
90
90
|
|
91
|
-
|
92
|
-
is also a Google group at https://groups.google.com/forum/#!forum/compositekeys,
|
93
|
-
but you'll have better luck getting support using GitHub.
|
91
|
+
For help please visit https://github.com/composite-primary-keys/composite_primary_keys.
|
94
92
|
|
95
93
|
== Author
|
96
94
|
|
@@ -68,11 +68,9 @@ require 'active_record/relation/query_methods'
|
|
68
68
|
|
69
69
|
require 'active_record/validations/uniqueness'
|
70
70
|
|
71
|
-
|
72
71
|
# CPK files
|
73
72
|
require 'composite_primary_keys/active_model/dirty'
|
74
73
|
require 'composite_primary_keys/persistence'
|
75
|
-
require 'composite_primary_keys/active_record_overides'
|
76
74
|
require 'composite_primary_keys/base'
|
77
75
|
require 'composite_primary_keys/core'
|
78
76
|
require 'composite_primary_keys/composite_arrays'
|
@@ -53,16 +53,6 @@ module CompositePrimaryKeys
|
|
53
53
|
true
|
54
54
|
end
|
55
55
|
end
|
56
|
-
|
57
|
-
def create_record(attribute_names = @attributes.keys)
|
58
|
-
attributes_values = arel_attributes_with_values_for_create(attribute_names)
|
59
|
-
|
60
|
-
new_id = self.class.unscoped.insert attributes_values
|
61
|
-
self.id ||= new_id if self.class.primary_key
|
62
|
-
|
63
|
-
@new_record = false
|
64
|
-
id
|
65
|
-
end
|
66
56
|
end
|
67
57
|
end
|
68
58
|
end
|
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: 7.0.
|
4
|
+
version: 7.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charlie Savage
|
@@ -38,7 +38,6 @@ files:
|
|
38
38
|
- install.rb
|
39
39
|
- lib/composite_primary_keys.rb
|
40
40
|
- lib/composite_primary_keys/active_model/dirty.rb
|
41
|
-
- lib/composite_primary_keys/active_record_overides.rb
|
42
41
|
- lib/composite_primary_keys/associations/association.rb
|
43
42
|
- lib/composite_primary_keys/associations/association_scope.rb
|
44
43
|
- lib/composite_primary_keys/associations/has_and_belongs_to_many_association.rb
|
@@ -1,42 +0,0 @@
|
|
1
|
-
module CompositePrimaryKeys
|
2
|
-
module ActiveRecord
|
3
|
-
module Overides
|
4
|
-
|
5
|
-
# This override ensures that pkeys are set on the instance when records are created.
|
6
|
-
# However, while ActiveRecord::Persistence defines a create_record method
|
7
|
-
# the call in create_or_update is actually calling the method create_record in the Dirty concern
|
8
|
-
# which removes the pkey attrs and also sets updated/created at timestamps
|
9
|
-
# For some reason when we overide here we lose dirty!
|
10
|
-
# So, for now, timestamps are recorded explicitly
|
11
|
-
def create_record(attribute_names = nil)
|
12
|
-
run_callbacks(:create) do
|
13
|
-
record_timestamps!
|
14
|
-
attribute_names ||= keys_for_partial_write
|
15
|
-
attributes_values = arel_attributes_with_values_for_create(attribute_names)
|
16
|
-
|
17
|
-
new_id = self.class.unscoped.insert attributes_values
|
18
|
-
|
19
|
-
# DB like MySQL doesn't return the newly inserted result.
|
20
|
-
# self.id cannot be updated for this case.
|
21
|
-
self.id = new_id if self.class.primary_key and new_id.kind_of?(Array)
|
22
|
-
|
23
|
-
@new_record = false
|
24
|
-
id
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def record_timestamps!
|
29
|
-
if self.record_timestamps
|
30
|
-
current_time = current_time_from_proper_timezone
|
31
|
-
|
32
|
-
all_timestamp_attributes.each do |column|
|
33
|
-
if respond_to?(column) && respond_to?("#{column}=") && self.send(column).nil?
|
34
|
-
write_attribute(column.to_s, current_time)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|