composite_primary_keys 12.0.0.rc3 → 12.0.0.rc4
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec4037eff014f3dc3de08ec0fecbe5d26e3555fc6dd68a250f717b1b0301c9e5
|
4
|
+
data.tar.gz: 57a521ac08b5d76a3e7781d3f644cfb574fb48ed32dc611034dfd413fd0375fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6880df1467fa15dba63e20264a69149d212cfb7c0be4068e6817ad485856894df879b01d76b6f44ba0cb1919986890186d793c638a69396de9434873659f775
|
7
|
+
data.tar.gz: f63e9d569bbaf62d178979115f61a6eafdb3ad5537e30cb05b6bc791ad3106a99664935a95c6009e88df9d3aeb859d677cda0d9b787b3e06702706f0e3cc2153
|
@@ -31,6 +31,8 @@ unless defined?(ActiveRecord)
|
|
31
31
|
end
|
32
32
|
|
33
33
|
# AR files we override
|
34
|
+
require 'active_record/attribute_methods'
|
35
|
+
require 'active_record/autosave_association'
|
34
36
|
require 'active_record/counter_cache'
|
35
37
|
require 'active_record/fixtures'
|
36
38
|
require 'active_record/model_schema'
|
@@ -38,8 +40,7 @@ require 'active_record/persistence'
|
|
38
40
|
require 'active_record/reflection'
|
39
41
|
require 'active_record/relation'
|
40
42
|
require 'active_record/sanitization'
|
41
|
-
require 'active_record/
|
42
|
-
require 'active_record/autosave_association'
|
43
|
+
require 'active_record/transactions'
|
43
44
|
|
44
45
|
require 'active_record/associations/association'
|
45
46
|
require 'active_record/associations/association_scope'
|
@@ -64,6 +65,8 @@ require 'active_record/connection_adapters/postgresql/database_statements'
|
|
64
65
|
require 'active_record/relation/where_clause'
|
65
66
|
|
66
67
|
# CPK files
|
68
|
+
require 'composite_primary_keys/attribute_methods'
|
69
|
+
require 'composite_primary_keys/autosave_association'
|
67
70
|
require 'composite_primary_keys/persistence'
|
68
71
|
require 'composite_primary_keys/base'
|
69
72
|
require 'composite_primary_keys/core'
|
@@ -74,8 +77,7 @@ require 'composite_primary_keys/fixtures'
|
|
74
77
|
require 'composite_primary_keys/reflection'
|
75
78
|
require 'composite_primary_keys/relation'
|
76
79
|
require 'composite_primary_keys/sanitization'
|
77
|
-
require 'composite_primary_keys/
|
78
|
-
require 'composite_primary_keys/autosave_association'
|
80
|
+
require 'composite_primary_keys/transactions'
|
79
81
|
require 'composite_primary_keys/version'
|
80
82
|
|
81
83
|
require 'composite_primary_keys/associations/association'
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module Transactions
|
3
|
+
# Restore the new record state and id of a record that was previously saved by a call to save_record_state.
|
4
|
+
def restore_transaction_record_state(force_restore_state = false)
|
5
|
+
if restore_state = @_start_transaction_state
|
6
|
+
if force_restore_state || restore_state[:level] <= 1
|
7
|
+
@new_record = restore_state[:new_record]
|
8
|
+
@destroyed = restore_state[:destroyed]
|
9
|
+
@attributes = restore_state[:attributes].map do |attr|
|
10
|
+
value = @attributes.fetch_value(attr.name)
|
11
|
+
attr = attr.with_value_from_user(value) if attr.value != value
|
12
|
+
attr
|
13
|
+
end
|
14
|
+
@mutations_from_database = nil
|
15
|
+
@mutations_before_last_save = nil
|
16
|
+
|
17
|
+
# CPK
|
18
|
+
if self.composite?
|
19
|
+
values = @primary_key.map {|attribute| @attributes.fetch_value(attribute)}
|
20
|
+
restore_id = restore_state[:id]
|
21
|
+
if values != restore_id
|
22
|
+
@primary_key.each_with_index do |attribute, i|
|
23
|
+
@attributes.write_from_user(attribute, restore_id[i])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
elsif @attributes.fetch_value(@primary_key) != restore_state[:id]
|
27
|
+
@attributes.write_from_user(@primary_key, restore_state[:id])
|
28
|
+
end
|
29
|
+
freeze if restore_state[:frozen?]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: composite_primary_keys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 12.0.0.
|
4
|
+
version: 12.0.0.rc4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charlie Savage
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- lib/composite_primary_keys/relation/query_methods.rb
|
129
129
|
- lib/composite_primary_keys/relation/where_clause.rb
|
130
130
|
- lib/composite_primary_keys/sanitization.rb
|
131
|
+
- lib/composite_primary_keys/transactions.rb
|
131
132
|
- lib/composite_primary_keys/validations/uniqueness.rb
|
132
133
|
- lib/composite_primary_keys/version.rb
|
133
134
|
- scripts/console.rb
|