composite_primary_keys 13.0.7 → 14.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.rdoc +50 -1
- data/README.rdoc +182 -181
- data/Rakefile +1 -1
- data/lib/composite_primary_keys/associations/association.rb +2 -2
- data/lib/composite_primary_keys/associations/association_scope.rb +1 -1
- data/lib/composite_primary_keys/associations/collection_association.rb +38 -31
- data/lib/composite_primary_keys/associations/has_many_through_association.rb +19 -0
- data/lib/composite_primary_keys/associations/preloader/association.rb +52 -61
- data/lib/composite_primary_keys/autosave_association.rb +60 -60
- data/lib/composite_primary_keys/composite_arrays.rb +88 -86
- data/lib/composite_primary_keys/composite_predicates.rb +121 -120
- data/lib/composite_primary_keys/connection_adapters/abstract/database_statements.rb +1 -2
- data/lib/composite_primary_keys/nested_attributes.rb +2 -2
- data/lib/composite_primary_keys/persistence.rb +96 -83
- data/lib/composite_primary_keys/relation/calculations.rb +110 -104
- data/lib/composite_primary_keys/relation/query_methods.rb +14 -16
- data/lib/composite_primary_keys/relation.rb +2 -0
- data/lib/composite_primary_keys/validations/uniqueness.rb +40 -32
- data/lib/composite_primary_keys/version.rb +2 -2
- data/lib/composite_primary_keys.rb +117 -119
- data/scripts/console.rb +2 -2
- data/tasks/databases/trilogy.rake +23 -0
- data/test/abstract_unit.rb +124 -114
- data/test/connections/databases.ci.yml +10 -0
- data/test/fixtures/admin.rb +4 -0
- data/test/fixtures/comments.yml +6 -0
- data/test/fixtures/db_definitions/db2-create-tables.sql +34 -0
- data/test/fixtures/db_definitions/db2-drop-tables.sql +7 -1
- data/test/fixtures/db_definitions/mysql.sql +23 -0
- data/test/fixtures/db_definitions/oracle.drop.sql +4 -0
- data/test/fixtures/db_definitions/oracle.sql +21 -0
- data/test/fixtures/db_definitions/postgresql.sql +23 -0
- data/test/fixtures/db_definitions/sqlite.sql +21 -0
- data/test/fixtures/db_definitions/sqlserver.sql +23 -0
- data/test/fixtures/department.rb +20 -16
- data/test/fixtures/moderator.rb +4 -0
- data/test/fixtures/room.rb +4 -1
- data/test/fixtures/room_assignment.rb +18 -14
- data/test/fixtures/staff_room.rb +6 -0
- data/test/fixtures/staff_room_key.rb +6 -0
- data/test/fixtures/user.rb +3 -0
- data/test/fixtures/user_with_polymorphic_name.rb +9 -0
- data/test/test_associations.rb +403 -372
- data/test/test_composite_arrays.rb +44 -38
- data/test/test_has_one_through.rb +30 -0
- data/test/test_nested_attributes.rb +23 -0
- data/test/test_polymorphic.rb +6 -0
- metadata +14 -7
- data/lib/composite_primary_keys/associations/through_association.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4675084d63630478cb5ad93843fe68c06e1820cc228fd8a1f95338851b901bd
|
4
|
+
data.tar.gz: ed8a13dcf2aee66e3fcf20f89e14049660eb7ee00341f9967a95cfd23dbbd259
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18089b861f3fd8bf7d6adf998c92235f34e3e786aa7de12590988f68580a63eb0551e338b59cc491e6d322a429e143f67245bebc85137d11f5bc087faa5abbfe
|
7
|
+
data.tar.gz: 5bb22276acefd46ed09e078bb999df86d7e1885304b855c7e6493733d13f859cd9a31b58177c971825d874b57fb5388d33dc6d3f715d58aa344b1f3f8e415f67
|
data/History.rdoc
CHANGED
@@ -1,3 +1,52 @@
|
|
1
|
+
== 14.0.9 (2023-12-03)
|
2
|
+
* Fix Error for Array-Based Composite Keys in nested_attribute (T.S.)
|
3
|
+
|
4
|
+
== 14.0.8 (2023-11-24)
|
5
|
+
* Support polymorphic_name (Vladimir Kochnev)
|
6
|
+
* Fix HasOneThrough association (kyori19)
|
7
|
+
|
8
|
+
== 14.0.7 (2023-11-04)
|
9
|
+
* Add support for Trilogy Adapter (Zack Mariscal)
|
10
|
+
* Add Dockerfile and Docker compose support (Zack Mariscal)
|
11
|
+
* Support polymorphic_name (Vladimir Kochnev)
|
12
|
+
* Fix HasOneThrough association (kyori19)
|
13
|
+
|
14
|
+
== 14.0.6 (2023-02-04)
|
15
|
+
* Port fix for #573 (Charlie Savage)
|
16
|
+
* Port fix for fix #577 (Charlie Savage)
|
17
|
+
|
18
|
+
== 14.0.5 (2023-02-04)
|
19
|
+
* Improve query generation for cpk_in_predicate. This reduces the length of
|
20
|
+
queries when loading many keys and enables Postgres to use index scans
|
21
|
+
more frequently. (Andrew Kiellor)
|
22
|
+
* Add Ruby 3.2 to CI and update checkout action versions (Peter Goldstein)
|
23
|
+
* Fix grammatical correction in README.rdoc (Sam Corl)
|
24
|
+
* Add an assertion for previously_new_record? (Akinori Musha)
|
25
|
+
* Fix validate_each (Benjamin Fleischer)
|
26
|
+
* Reduce ambiguity by avoiding #normalize (Mitsuhiro Shibuya)
|
27
|
+
* Accept strings in has_many ids assignment (Mitsuhiro Shibuya)
|
28
|
+
* Make CompositeKeys respond to #to_param consistently with ActiveRecord::Base (Mitsuhiro Shibuya)
|
29
|
+
|
30
|
+
== 14.0.4 (2022-02-13)
|
31
|
+
* Fix for changed method in Rails 7.0.2 (Yota)
|
32
|
+
|
33
|
+
== 14.0.3 (2022-01-09)
|
34
|
+
* Remove override on ActiveRecord::Base#to_param. That method has moved to Integration
|
35
|
+
so no longer works. #541. (Charlie Savage)
|
36
|
+
* Check if an assocation is polymorhpic. Fixes #558.
|
37
|
+
|
38
|
+
== 14.0.2 (2022-01-09)
|
39
|
+
* Fix scoped associations take #2 (Charlie Savage)
|
40
|
+
|
41
|
+
== 14.0.1 (2022-01-9)
|
42
|
+
* Fix mistake in Gemfile (Charlie Savage)
|
43
|
+
|
44
|
+
== 14.0.0 (2022-01-9)
|
45
|
+
* Update to ActiveRecord 7.0 (Sammy Larbi)
|
46
|
+
|
47
|
+
==13.0.8 (2023-11-24)
|
48
|
+
Fix ‘polymorphic_name` support (Vladimir Kochnev)
|
49
|
+
|
1
50
|
== 13.0.7 (2023-02-04)
|
2
51
|
* Fix #573 (Charlie Savage)
|
3
52
|
|
@@ -10,7 +59,7 @@ queries when loading many keys and enables Postgres to use index scans
|
|
10
59
|
more frequently. (Andrew Kiellor)
|
11
60
|
|
12
61
|
== 13.0.4 (2022-12-05)
|
13
|
-
* Fix previously_new_record? not being set to true after create
|
62
|
+
* Fix previously_new_record? not being set to true after create (Akinori MUSHA)
|
14
63
|
|
15
64
|
== 13.0.3 (2022-01-09)
|
16
65
|
* Remove override on ActiveRecord::Base#to_param. That method has moved to Integration
|
data/README.rdoc
CHANGED
@@ -1,181 +1,182 @@
|
|
1
|
-
= Composite Primary Keys for ActiveRecords
|
2
|
-
|
3
|
-
== Summary
|
4
|
-
|
5
|
-
|
6
|
-
This gem, composite_primary_keys, or CPK for short, extends ActiveRecord
|
7
|
-
to support composite keys.
|
8
|
-
|
9
|
-
== Installation
|
10
|
-
|
11
|
-
gem install composite_primary_keys
|
12
|
-
|
13
|
-
If you are using Rails add the following to your Gemfile:
|
14
|
-
|
15
|
-
gem 'composite_primary_keys', '=x.x.x' (see next section about what version to use)
|
16
|
-
|
17
|
-
== Versions
|
18
|
-
|
19
|
-
Every major version of ActiveRecord has included numerous internal changes. As a result,
|
20
|
-
CPK has to be rewritten for each version of ActiveRecord. To help keep
|
21
|
-
things straight, here is the mapping:
|
22
|
-
|
23
|
-
Version
|
24
|
-
Version
|
25
|
-
Version
|
26
|
-
Version
|
27
|
-
Version
|
28
|
-
Version
|
29
|
-
Version
|
30
|
-
Version
|
31
|
-
Version
|
32
|
-
Version
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
belongs_to :
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
Membership.primary_key
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
*
|
97
|
-
*
|
98
|
-
*
|
99
|
-
*
|
100
|
-
*
|
101
|
-
*
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
*
|
110
|
-
*
|
111
|
-
*
|
112
|
-
*
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
bundler
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
1
|
+
= Composite Primary Keys for ActiveRecords
|
2
|
+
|
3
|
+
== Summary
|
4
|
+
|
5
|
+
ActiveRecord infamously doesn't support composite primary keys.
|
6
|
+
This gem, composite_primary_keys, or CPK for short, extends ActiveRecord
|
7
|
+
to support composite keys.
|
8
|
+
|
9
|
+
== Installation
|
10
|
+
|
11
|
+
gem install composite_primary_keys
|
12
|
+
|
13
|
+
If you are using Rails add the following to your Gemfile:
|
14
|
+
|
15
|
+
gem 'composite_primary_keys', '=x.x.x' (see next section about what version to use)
|
16
|
+
|
17
|
+
== Versions
|
18
|
+
|
19
|
+
Every major version of ActiveRecord has included numerous internal changes. As a result,
|
20
|
+
CPK has to be rewritten for each version of ActiveRecord. To help keep
|
21
|
+
things straight, here is the mapping:
|
22
|
+
|
23
|
+
Version 14.x is designed to work with ActiveRecord 7.0.x
|
24
|
+
Version 13.x is designed to work with ActiveRecord 6.1.x
|
25
|
+
Version 12.x is designed to work with ActiveRecord 6.0.x
|
26
|
+
Version 11.x is designed to work with ActiveRecord 5.2.x
|
27
|
+
Version 10.x is designed to work with ActiveRecord 5.1.x
|
28
|
+
Version 9.x is designed to work with ActiveRecord 5.0.x
|
29
|
+
Version 8.x is designed to work with ActiveRecord 4.2.x
|
30
|
+
Version 7.x is designed to work with ActiveRecord 4.1.x
|
31
|
+
Version 6.x is designed to work with ActiveRecord 4.0.x
|
32
|
+
Version 5.x is designed to work with ActiveRecord 3.2.x
|
33
|
+
Version 4.x is designed to work with ActiveRecord 3.1.x
|
34
|
+
|
35
|
+
Run the following command to list available versions:
|
36
|
+
|
37
|
+
gem list composite_primary_keys -ra
|
38
|
+
|
39
|
+
== The basics
|
40
|
+
|
41
|
+
A model with composite primary keys is defined like this:
|
42
|
+
|
43
|
+
class Membership < ActiveRecord::Base
|
44
|
+
self.primary_keys = :user_id, :group_id
|
45
|
+
belongs_to :user
|
46
|
+
belongs_to :group
|
47
|
+
has_many :statuses, :class_name => 'MembershipStatus', :foreign_key => [:user_id, :group_id]
|
48
|
+
end
|
49
|
+
|
50
|
+
Note the addition of the line:
|
51
|
+
|
52
|
+
self.primary_keys = :user_id, :group_id
|
53
|
+
|
54
|
+
|
55
|
+
A model associated with a composite key model is defined like this:
|
56
|
+
|
57
|
+
class MembershipStatus < ActiveRecord::Base
|
58
|
+
belongs_to :membership, :foreign_key => [:user_id, :group_id]
|
59
|
+
end
|
60
|
+
|
61
|
+
That is, associations can include composite keys too. All Rails association types are supported. Nice.
|
62
|
+
|
63
|
+
== Usage
|
64
|
+
|
65
|
+
Once you’ve created your models to specify composite primary keys (such as the Membership class)
|
66
|
+
and associations (such as MembershipStatus#membership), you can use them like any normal model
|
67
|
+
with associations.
|
68
|
+
|
69
|
+
But first, lets check out our primary keys.
|
70
|
+
|
71
|
+
MembershipStatus.primary_key # => "id" # normal single key
|
72
|
+
Membership.primary_key # => [:user_id, :group_id] # composite keys
|
73
|
+
Membership.primary_key.to_s # => "user_id,group_id"
|
74
|
+
|
75
|
+
Now we want to be able to find instances using the same syntax we always use for ActiveRecords.
|
76
|
+
|
77
|
+
MembershipStatus.find(1) # single id returns single instance
|
78
|
+
=> <MembershipStatus:0x392a8c8 @attributes={"id"=>"1", "status"=>"Active"}>
|
79
|
+
|
80
|
+
Membership.find([1,1]) # composite ids returns single instance
|
81
|
+
=> <Membership:0x39218b0 @attributes={"user_id"=>"1", "group_id"=>"1"}>
|
82
|
+
|
83
|
+
Notice the use of an array to specify the composite key values.
|
84
|
+
|
85
|
+
NOTE - API CHANGE. CPK Version 6.x and earlier used to allow composite keys to be listed out
|
86
|
+
like this:
|
87
|
+
|
88
|
+
Membership.find(1,1)
|
89
|
+
|
90
|
+
This usage is no longer supported.
|
91
|
+
|
92
|
+
== Databases
|
93
|
+
|
94
|
+
CPK supports the following databases:
|
95
|
+
|
96
|
+
* PostgreSQL
|
97
|
+
* MySQL
|
98
|
+
* MariaDB
|
99
|
+
* Oracle
|
100
|
+
* DB2
|
101
|
+
* SQLite
|
102
|
+
* SQLServer
|
103
|
+
|
104
|
+
== Tests
|
105
|
+
|
106
|
+
To run tests you first need to install the appropriate gems for the database you want to test. Database gems are
|
107
|
+
divided into the following bundler groups:
|
108
|
+
|
109
|
+
* mysql
|
110
|
+
* oracle
|
111
|
+
* postgresql
|
112
|
+
* sqlite
|
113
|
+
* sqlserver
|
114
|
+
|
115
|
+
Since it is likely you do not have all the above databases installed on your computer, you want to install just the
|
116
|
+
gems for your database. For example, to test postgresql you would install the appropriate gems like this:
|
117
|
+
|
118
|
+
bundler config set --local without "mysql oracle sqlite sqlserver"
|
119
|
+
bundler install
|
120
|
+
|
121
|
+
Once you have installed the appropriate gems, the next step is to create the test database. There is a rake
|
122
|
+
command for each database. Using our example:
|
123
|
+
|
124
|
+
rake postgresql:build_database
|
125
|
+
|
126
|
+
You can also rebuild the database if it already exists using this command:
|
127
|
+
|
128
|
+
rake postgresql:rebuild_database
|
129
|
+
|
130
|
+
To get a list of commands for your database use:
|
131
|
+
|
132
|
+
Rake -T
|
133
|
+
|
134
|
+
Finally, to run tests:
|
135
|
+
|
136
|
+
rake postgresql:test
|
137
|
+
|
138
|
+
Travis build status: {<img src="https://travis-ci.com/composite-primary-keys/composite_primary_keys.svg" alt="Build Status" />}[https://travis-ci.com/composite-primary-keys/composite_primary_keys]
|
139
|
+
|
140
|
+
=== DB2
|
141
|
+
|
142
|
+
DB2 is no longer supported due to difficulties in getting the ibm_db2 gem to build. Thus tests
|
143
|
+
have not been run against db2.
|
144
|
+
|
145
|
+
=== MariaDb (mysql)
|
146
|
+
|
147
|
+
MariaDb is fully supported with all tests passing.
|
148
|
+
|
149
|
+
=== Oracle
|
150
|
+
|
151
|
+
Oracle is fully supported with all tests passing.
|
152
|
+
|
153
|
+
=== Postgresql
|
154
|
+
|
155
|
+
Postgresql is fully supported with all tests passing.
|
156
|
+
|
157
|
+
=== Sqlite 3
|
158
|
+
|
159
|
+
The sqlite database is created at the path composite_primary_keys/db. Note you must *first* create the database using the
|
160
|
+
built-in rake task before running tests:
|
161
|
+
|
162
|
+
rake sqlite:build_database
|
163
|
+
|
164
|
+
For sqlite3 to work correctly, you must manually require 'composite_primary_keys/connection_adapters/sqlite3_adapter' after
|
165
|
+
loading the CPK gem.
|
166
|
+
|
167
|
+
=== SqlServer
|
168
|
+
|
169
|
+
SqlServer is partially supported. There are a number of failing tests - patches welcomed.
|
170
|
+
|
171
|
+
== Questions, Discussion and Contributions
|
172
|
+
|
173
|
+
For help please visit https://github.com/composite-primary-keys/composite_primary_keys.
|
174
|
+
|
175
|
+
== Author
|
176
|
+
|
177
|
+
First version was written by Dr Nic Williams.
|
178
|
+
|
179
|
+
Maintained by Charlie Savage
|
180
|
+
|
181
|
+
Contributions by many!
|
182
|
+
|
data/Rakefile
CHANGED
@@ -23,7 +23,7 @@ Dir.glob('tasks/**/*.rake').each do |rake_file|
|
|
23
23
|
end
|
24
24
|
|
25
25
|
# Set up test tasks for each supported connection adapter
|
26
|
-
%w(mysql sqlite oracle oracle_enhanced postgresql ibm_db sqlserver).each do |adapter|
|
26
|
+
%w(mysql sqlite oracle oracle_enhanced postgresql ibm_db sqlserver trilogy).each do |adapter|
|
27
27
|
namespace adapter do
|
28
28
|
desc "Run tests using the #{adapter} adapter"
|
29
29
|
task "test" do
|
@@ -1,32 +1,39 @@
|
|
1
|
-
module CompositePrimaryKeys
|
2
|
-
module CollectionAssociation
|
3
|
-
def ids_writer(ids)
|
4
|
-
primary_key = reflection.association_primary_key
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
records = klass.where(
|
17
|
-
r.
|
18
|
-
end.values_at(*ids).compact
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
1
|
+
module CompositePrimaryKeys
|
2
|
+
module CollectionAssociation
|
3
|
+
def ids_writer(ids)
|
4
|
+
primary_key = reflection.association_primary_key
|
5
|
+
ids = Array(ids).reject(&:blank?)
|
6
|
+
|
7
|
+
# CPK-
|
8
|
+
if primary_key.is_a?(Array)
|
9
|
+
ids = ids.map { |id| CompositePrimaryKeys::CompositeKeys.parse(id) }
|
10
|
+
primary_key.each_with_index do |key, i|
|
11
|
+
pk_type = klass.type_for_attribute(key)
|
12
|
+
ids.each { |id| id[i] = pk_type.cast(id[i]) }
|
13
|
+
end
|
14
|
+
|
15
|
+
predicate = CompositePrimaryKeys::Predicates.cpk_in_predicate(klass.arel_table, reflection.association_primary_key, ids)
|
16
|
+
records = klass.where(predicate).index_by do |r|
|
17
|
+
reflection.association_primary_key.map{ |k| r.send(k) }
|
18
|
+
end.values_at(*ids).compact
|
19
|
+
else
|
20
|
+
pk_type = klass.type_for_attribute(primary_key)
|
21
|
+
ids.map! { |i| pk_type.cast(i) }
|
22
|
+
|
23
|
+
records = klass.where(primary_key => ids).index_by do |r|
|
24
|
+
r.public_send(primary_key)
|
25
|
+
end.values_at(*ids).compact
|
26
|
+
end
|
27
|
+
|
28
|
+
if records.size != ids.size
|
29
|
+
found_ids = records.map { |record| record.public_send(primary_key) }
|
30
|
+
not_found_ids = ids - found_ids
|
31
|
+
klass.all.raise_record_not_found_exception!(ids, records.size, ids.size, primary_key, not_found_ids)
|
32
|
+
else
|
33
|
+
replace(records)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
32
39
|
ActiveRecord::Associations::CollectionAssociation.prepend CompositePrimaryKeys::CollectionAssociation
|
@@ -23,6 +23,25 @@ module ActiveRecord
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
26
|
+
|
27
|
+
alias :original_construct_join_attributes :construct_join_attributes
|
28
|
+
|
29
|
+
def construct_join_attributes(*records)
|
30
|
+
# CPK
|
31
|
+
if !self.source_reflection.polymorphic? && source_reflection.klass.composite?
|
32
|
+
ensure_mutable
|
33
|
+
|
34
|
+
ids = records.map do |record|
|
35
|
+
source_reflection.association_primary_key(reflection.klass).map do |key|
|
36
|
+
record.send(key)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
cpk_in_predicate(through_association.scope.klass.arel_table, source_reflection.foreign_key, ids)
|
41
|
+
else
|
42
|
+
original_construct_join_attributes(*records)
|
43
|
+
end
|
44
|
+
end
|
26
45
|
end
|
27
46
|
end
|
28
47
|
end
|