composite_primary_keys 12.0.2 → 12.0.10
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 +880 -841
- data/README.rdoc +180 -179
- data/lib/composite_primary_keys/active_model/attribute_assignment.rb +19 -0
- data/lib/composite_primary_keys/arel/sqlserver.rb +1 -3
- data/lib/composite_primary_keys/associations/association_scope.rb +68 -68
- data/lib/composite_primary_keys/associations/join_dependency.rb +103 -103
- data/lib/composite_primary_keys/associations/through_association.rb +2 -1
- data/lib/composite_primary_keys/attribute_methods/primary_key.rb +13 -0
- data/lib/composite_primary_keys/attribute_methods/read.rb +30 -30
- data/lib/composite_primary_keys/attribute_methods/write.rb +35 -35
- data/lib/composite_primary_keys/attribute_methods.rb +9 -9
- data/lib/composite_primary_keys/base.rb +141 -130
- data/lib/composite_primary_keys/composite_arrays.rb +0 -8
- data/lib/composite_primary_keys/connection_adapters/abstract/database_statements.rb +37 -17
- data/lib/composite_primary_keys/connection_adapters/sqlserver/database_statements.rb +44 -23
- data/lib/composite_primary_keys/core.rb +48 -48
- data/lib/composite_primary_keys/persistence.rb +82 -81
- data/lib/composite_primary_keys/reflection.rb +29 -29
- data/lib/composite_primary_keys/relation/batches.rb +1 -1
- data/lib/composite_primary_keys/relation/calculations.rb +81 -81
- data/lib/composite_primary_keys/relation/finder_methods.rb +235 -235
- data/lib/composite_primary_keys/relation/predicate_builder/association_query_value.rb +20 -20
- data/lib/composite_primary_keys/relation/query_methods.rb +42 -42
- data/lib/composite_primary_keys/relation/where_clause.rb +23 -23
- data/lib/composite_primary_keys/relation.rb +193 -118
- data/lib/composite_primary_keys/version.rb +8 -8
- data/lib/composite_primary_keys.rb +117 -118
- data/test/abstract_unit.rb +114 -113
- data/test/connections/databases.ci.yml +22 -19
- data/test/fixtures/article.rb +4 -0
- data/test/fixtures/articles.yml +4 -3
- data/test/fixtures/comment.rb +1 -3
- data/test/fixtures/comments.yml +10 -9
- data/test/fixtures/db_definitions/db2-create-tables.sql +112 -126
- data/test/fixtures/db_definitions/db2-drop-tables.sql +17 -19
- data/test/fixtures/db_definitions/mysql.sql +180 -217
- data/test/fixtures/db_definitions/oracle.drop.sql +42 -48
- data/test/fixtures/db_definitions/oracle.sql +200 -236
- data/test/fixtures/db_definitions/postgresql.sql +183 -220
- data/test/fixtures/db_definitions/sqlite.sql +170 -206
- data/test/fixtures/db_definitions/sqlserver.sql +176 -212
- data/test/fixtures/department.rb +16 -11
- data/test/fixtures/departments.yml +15 -15
- data/test/fixtures/employees.yml +27 -27
- data/test/fixtures/readings.yml +2 -2
- data/test/fixtures/restaurants_suburbs.yml +11 -11
- data/test/fixtures/streets.yml +16 -16
- data/test/fixtures/suburbs.yml +14 -14
- data/test/fixtures/user.rb +11 -10
- data/test/test_associations.rb +358 -351
- data/test/test_attributes.rb +60 -60
- data/test/test_calculations.rb +42 -42
- data/test/test_create.rb +218 -183
- data/test/test_delete.rb +182 -179
- data/test/test_exists.rb +39 -39
- data/test/test_find.rb +164 -145
- data/test/test_habtm.rb +2 -2
- data/test/test_ids.rb +112 -116
- data/test/test_nested_attributes.rb +67 -124
- data/test/test_polymorphic.rb +29 -13
- data/test/test_preload.rb +4 -3
- data/test/test_serialize.rb +2 -2
- data/test/test_update.rb +96 -78
- metadata +4 -19
- data/test/fixtures/hack.rb +0 -5
- data/test/fixtures/hacks.yml +0 -3
- data/test/fixtures/pk_called_id.rb +0 -5
- data/test/fixtures/pk_called_ids.yml +0 -11
- data/test/fixtures/reference_code_using_composite_key_alias.rb +0 -8
- data/test/fixtures/reference_code_using_simple_key_alias.rb +0 -8
- data/test/fixtures/seat.rb +0 -5
- data/test/fixtures/seats.yml +0 -9
- data/test/fixtures/topic.rb +0 -6
- data/test/fixtures/topic_source.rb +0 -7
- data/test/test_aliases.rb +0 -18
- data/test/test_enum.rb +0 -21
- data/test/test_suite.rb +0 -35
@@ -1,118 +1,193 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
class Relation
|
3
|
-
alias :initialize_without_cpk :initialize
|
4
|
-
def initialize(klass, table: klass.arel_table, predicate_builder: klass.predicate_builder, values: {})
|
5
|
-
initialize_without_cpk(klass, table: table, predicate_builder: predicate_builder, values: values)
|
6
|
-
add_cpk_support if klass && klass.composite?
|
7
|
-
end
|
8
|
-
|
9
|
-
alias :initialize_copy_without_cpk :initialize_copy
|
10
|
-
def initialize_copy(other)
|
11
|
-
initialize_copy_without_cpk(other)
|
12
|
-
add_cpk_support if klass.composite?
|
13
|
-
end
|
14
|
-
|
15
|
-
def add_cpk_support
|
16
|
-
extend CompositePrimaryKeys::CompositeRelation
|
17
|
-
end
|
18
|
-
|
19
|
-
def update_all(updates)
|
20
|
-
raise ArgumentError, "Empty list of attributes to change" if updates.blank?
|
21
|
-
|
22
|
-
if eager_loading?
|
23
|
-
relation = apply_join_dependency
|
24
|
-
return relation.update_all(updates)
|
25
|
-
end
|
26
|
-
|
27
|
-
stmt = Arel::UpdateManager.new
|
28
|
-
# CPK
|
29
|
-
if @klass.composite?
|
30
|
-
stmt.table(
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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
|
-
if
|
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
|
-
|
1
|
+
module ActiveRecord
|
2
|
+
class Relation
|
3
|
+
alias :initialize_without_cpk :initialize
|
4
|
+
def initialize(klass, table: klass.arel_table, predicate_builder: klass.predicate_builder, values: {})
|
5
|
+
initialize_without_cpk(klass, table: table, predicate_builder: predicate_builder, values: values)
|
6
|
+
add_cpk_support if klass && klass.composite?
|
7
|
+
end
|
8
|
+
|
9
|
+
alias :initialize_copy_without_cpk :initialize_copy
|
10
|
+
def initialize_copy(other)
|
11
|
+
initialize_copy_without_cpk(other)
|
12
|
+
add_cpk_support if klass.composite?
|
13
|
+
end
|
14
|
+
|
15
|
+
def add_cpk_support
|
16
|
+
extend CompositePrimaryKeys::CompositeRelation
|
17
|
+
end
|
18
|
+
|
19
|
+
def update_all(updates)
|
20
|
+
raise ArgumentError, "Empty list of attributes to change" if updates.blank?
|
21
|
+
|
22
|
+
if eager_loading?
|
23
|
+
relation = apply_join_dependency
|
24
|
+
return relation.update_all(updates)
|
25
|
+
end
|
26
|
+
|
27
|
+
stmt = Arel::UpdateManager.new
|
28
|
+
# CPK
|
29
|
+
if @klass.composite?
|
30
|
+
stmt.table(arel_table)
|
31
|
+
cpk_subquery(stmt)
|
32
|
+
else
|
33
|
+
stmt.table(arel.join_sources.empty? ? table : arel.source)
|
34
|
+
stmt.key = arel_attribute(primary_key)
|
35
|
+
stmt.wheres = arel.constraints
|
36
|
+
end
|
37
|
+
stmt.take(arel.limit)
|
38
|
+
stmt.offset(arel.offset)
|
39
|
+
stmt.order(*arel.orders)
|
40
|
+
|
41
|
+
if updates.is_a?(Hash)
|
42
|
+
if klass.locking_enabled? &&
|
43
|
+
!updates.key?(klass.locking_column) &&
|
44
|
+
!updates.key?(klass.locking_column.to_sym)
|
45
|
+
attr = arel_attribute(klass.locking_column)
|
46
|
+
updates[attr.name] = _increment_attribute(attr)
|
47
|
+
end
|
48
|
+
stmt.set _substitute_values(updates)
|
49
|
+
else
|
50
|
+
stmt.set Arel.sql(klass.sanitize_sql_for_assignment(updates, table.name))
|
51
|
+
end
|
52
|
+
|
53
|
+
@klass.connection.update stmt, "#{@klass} Update All"
|
54
|
+
end
|
55
|
+
|
56
|
+
def delete_all
|
57
|
+
invalid_methods = INVALID_METHODS_FOR_DELETE_ALL.select do |method|
|
58
|
+
value = @values[method]
|
59
|
+
method == :distinct ? value : value&.any?
|
60
|
+
end
|
61
|
+
if invalid_methods.any?
|
62
|
+
raise ActiveRecordError.new("delete_all doesn't support #{invalid_methods.join(', ')}")
|
63
|
+
end
|
64
|
+
|
65
|
+
if eager_loading?
|
66
|
+
relation = apply_join_dependency
|
67
|
+
return relation.delete_all
|
68
|
+
end
|
69
|
+
|
70
|
+
stmt = Arel::DeleteManager.new
|
71
|
+
|
72
|
+
if @klass.composite?
|
73
|
+
stmt.from(arel_table)
|
74
|
+
cpk_subquery(stmt)
|
75
|
+
else
|
76
|
+
stmt.from(arel.join_sources.empty? ? table : arel.source)
|
77
|
+
stmt.key = arel_attribute(primary_key)
|
78
|
+
stmt.wheres = arel.constraints
|
79
|
+
end
|
80
|
+
|
81
|
+
stmt.take(arel.limit)
|
82
|
+
stmt.offset(arel.offset)
|
83
|
+
stmt.order(*arel.orders)
|
84
|
+
|
85
|
+
affected = @klass.connection.delete(stmt, "#{@klass} Destroy")
|
86
|
+
|
87
|
+
reset
|
88
|
+
affected
|
89
|
+
end
|
90
|
+
|
91
|
+
# CPK
|
92
|
+
def cpk_subquery(stmt)
|
93
|
+
# For update and delete statements we need a way to specify which records should
|
94
|
+
# get updated. By default, Rails creates a nested IN subquery that uses the primary
|
95
|
+
# key. Postgresql, Sqlite, MariaDb and Oracle support IN subqueries with multiple
|
96
|
+
# columns but MySQL and SqlServer do not. Instead SQL server supports EXISTS queries
|
97
|
+
# and MySQL supports obfuscated IN queries. Thus we need to check the type of
|
98
|
+
# database adapter to decide how to proceed.
|
99
|
+
if defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter) && connection.is_a?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)
|
100
|
+
cpk_mysql_subquery(stmt)
|
101
|
+
elsif defined?(ActiveRecord::ConnectionAdapters::SQLServerAdapter) && connection.is_a?(ActiveRecord::ConnectionAdapters::SQLServerAdapter)
|
102
|
+
cpk_exists_subquery(stmt)
|
103
|
+
else
|
104
|
+
cpk_in_subquery(stmt)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# Used by postgresql, sqlite, mariadb and oracle. Example query:
|
109
|
+
#
|
110
|
+
# UPDATE reference_codes
|
111
|
+
# SET ...
|
112
|
+
# WHERE (reference_codes.reference_type_id, reference_codes.reference_code) IN
|
113
|
+
# (SELECT reference_codes.reference_type_id, reference_codes.reference_code
|
114
|
+
# FROM reference_codes)
|
115
|
+
def cpk_in_subquery(stmt)
|
116
|
+
# Setup the subquery
|
117
|
+
subquery = arel.clone
|
118
|
+
subquery.projections = primary_keys.map do |key|
|
119
|
+
arel_table[key]
|
120
|
+
end
|
121
|
+
|
122
|
+
where_fields = primary_keys.map do |key|
|
123
|
+
arel_table[key]
|
124
|
+
end
|
125
|
+
where = Arel::Nodes::Grouping.new(where_fields).in(subquery)
|
126
|
+
stmt.wheres = [where]
|
127
|
+
end
|
128
|
+
|
129
|
+
# CPK. This is an alternative to IN subqueries. It is used by sqlserver.
|
130
|
+
# Example query:
|
131
|
+
#
|
132
|
+
# UPDATE reference_codes
|
133
|
+
# SET ...
|
134
|
+
# WHERE EXISTS
|
135
|
+
# (SELECT 1
|
136
|
+
# FROM reference_codes cpk_child
|
137
|
+
# WHERE reference_codes.reference_type_id = cpk_child.reference_type_id AND
|
138
|
+
# reference_codes.reference_code = cpk_child.reference_code)
|
139
|
+
def cpk_exists_subquery(stmt)
|
140
|
+
arel_attributes = primary_keys.map do |key|
|
141
|
+
arel_attribute(key)
|
142
|
+
end.to_composite_keys
|
143
|
+
|
144
|
+
# Clone the query
|
145
|
+
subselect = arel.clone
|
146
|
+
|
147
|
+
# Alias the table - we assume just one table
|
148
|
+
aliased_table = subselect.froms.first
|
149
|
+
aliased_table.table_alias = "cpk_child"
|
150
|
+
|
151
|
+
# Project - really we could just set this to "1"
|
152
|
+
subselect.projections = arel_attributes
|
153
|
+
|
154
|
+
# Setup correlation to the outer query via where clauses
|
155
|
+
primary_keys.map do |key|
|
156
|
+
outer_attribute = arel_table[key]
|
157
|
+
inner_attribute = aliased_table[key]
|
158
|
+
where = outer_attribute.eq(inner_attribute)
|
159
|
+
subselect.where(where)
|
160
|
+
end
|
161
|
+
stmt.wheres = [Arel::Nodes::Exists.new(subselect)]
|
162
|
+
end
|
163
|
+
|
164
|
+
# CPK. This is the old way CPK created subqueries and is used by MySql.
|
165
|
+
# MySQL does not support referencing the same table that is being UPDATEd or
|
166
|
+
# DELETEd in a subquery so we obfuscate it. The ugly query looks like this:
|
167
|
+
#
|
168
|
+
# UPDATE `reference_codes`
|
169
|
+
# SET ...
|
170
|
+
# WHERE (reference_codes.reference_type_id, reference_codes.reference_code) IN
|
171
|
+
# (SELECT reference_type_id,reference_code
|
172
|
+
# FROM (SELECT DISTINCT `reference_codes`.`reference_type_id`, `reference_codes`.`reference_code`
|
173
|
+
# FROM `reference_codes`) __active_record_temp)
|
174
|
+
def cpk_mysql_subquery(stmt)
|
175
|
+
arel_attributes = primary_keys.map do |key|
|
176
|
+
arel_attribute(key)
|
177
|
+
end.to_composite_keys
|
178
|
+
|
179
|
+
subselect = arel.clone
|
180
|
+
subselect.projections = arel_attributes
|
181
|
+
|
182
|
+
# Materialize subquery by adding distinct
|
183
|
+
# to work with MySQL 5.7.6 which sets optimizer_switch='derived_merge=on'
|
184
|
+
subselect.distinct unless arel.limit || arel.offset || arel.orders.any?
|
185
|
+
|
186
|
+
key_name = arel_attributes.map(&:name).join(',')
|
187
|
+
|
188
|
+
manager = Arel::SelectManager.new(subselect.as("__active_record_temp")).project(Arel.sql(key_name))
|
189
|
+
|
190
|
+
stmt.wheres = [Arel::Nodes::In.new(arel_attributes, manager.ast)]
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
module CompositePrimaryKeys
|
2
|
-
module VERSION
|
3
|
-
MAJOR = 12
|
4
|
-
MINOR = 0
|
5
|
-
TINY =
|
6
|
-
STRING = [MAJOR, MINOR, TINY].join('.')
|
7
|
-
end
|
8
|
-
end
|
1
|
+
module CompositePrimaryKeys
|
2
|
+
module VERSION
|
3
|
+
MAJOR = 12
|
4
|
+
MINOR = 0
|
5
|
+
TINY = 10
|
6
|
+
STRING = [MAJOR, MINOR, TINY].join('.')
|
7
|
+
end
|
8
|
+
end
|
@@ -1,118 +1,117 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2006-2016 Nic Williams and Charlie Savage
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# "Software"), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
require 'active_record/
|
36
|
-
require 'active_record/
|
37
|
-
require 'active_record/
|
38
|
-
require 'active_record/
|
39
|
-
require 'active_record/
|
40
|
-
require 'active_record/
|
41
|
-
require 'active_record/
|
42
|
-
require 'active_record/
|
43
|
-
require 'active_record/
|
44
|
-
|
45
|
-
|
46
|
-
require 'active_record/associations/
|
47
|
-
require 'active_record/associations/
|
48
|
-
require 'active_record/associations/
|
49
|
-
require 'active_record/associations/
|
50
|
-
require 'active_record/associations/
|
51
|
-
require 'active_record/associations/
|
52
|
-
require 'active_record/associations/
|
53
|
-
require 'active_record/associations/
|
54
|
-
require 'active_record/associations/
|
55
|
-
|
56
|
-
|
57
|
-
require 'active_record/attribute_methods/
|
58
|
-
require 'active_record/attribute_methods/
|
59
|
-
require 'active_record/
|
60
|
-
|
61
|
-
|
62
|
-
require 'active_record/connection_adapters/
|
63
|
-
require 'active_record/connection_adapters/
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
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
|
-
#require 'composite_primary_keys/arel/sqlserver'
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2006-2016 Nic Williams and Charlie Savage
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
unless defined?(ActiveRecord)
|
25
|
+
require 'rubygems'
|
26
|
+
gem 'activerecord', '~>6.0.0'
|
27
|
+
require 'active_record'
|
28
|
+
end
|
29
|
+
|
30
|
+
# ActiveModel files we override
|
31
|
+
# _write_attribute
|
32
|
+
require 'active_model/attribute_assignment'
|
33
|
+
|
34
|
+
# ActiveRecord files we override
|
35
|
+
require 'active_record/attribute_methods'
|
36
|
+
require 'active_record/autosave_association'
|
37
|
+
require 'active_record/counter_cache'
|
38
|
+
require 'active_record/fixtures'
|
39
|
+
require 'active_record/model_schema'
|
40
|
+
require 'active_record/persistence'
|
41
|
+
require 'active_record/reflection'
|
42
|
+
require 'active_record/relation'
|
43
|
+
require 'active_record/sanitization'
|
44
|
+
require 'active_record/transactions'
|
45
|
+
|
46
|
+
require 'active_record/associations/association'
|
47
|
+
require 'active_record/associations/association_scope'
|
48
|
+
require 'active_record/associations/foreign_association'
|
49
|
+
require 'active_record/associations/has_many_association'
|
50
|
+
require 'active_record/associations/has_many_through_association'
|
51
|
+
require 'active_record/associations/join_dependency'
|
52
|
+
require 'active_record/associations/preloader/association'
|
53
|
+
require 'active_record/associations/singular_association'
|
54
|
+
require 'active_record/associations/collection_association'
|
55
|
+
require 'active_record/associations/through_association'
|
56
|
+
|
57
|
+
require 'active_record/attribute_methods/primary_key'
|
58
|
+
require 'active_record/attribute_methods/read'
|
59
|
+
require 'active_record/attribute_methods/write'
|
60
|
+
require 'active_record/nested_attributes'
|
61
|
+
|
62
|
+
require 'active_record/connection_adapters/abstract/database_statements'
|
63
|
+
require 'active_record/connection_adapters/abstract_adapter'
|
64
|
+
require 'active_record/connection_adapters/postgresql/database_statements'
|
65
|
+
|
66
|
+
require 'active_record/relation/where_clause'
|
67
|
+
|
68
|
+
# CPK overrides
|
69
|
+
require_relative 'composite_primary_keys/active_model/attribute_assignment'
|
70
|
+
require_relative 'composite_primary_keys/attribute_methods'
|
71
|
+
require_relative 'composite_primary_keys/autosave_association'
|
72
|
+
require_relative 'composite_primary_keys/persistence'
|
73
|
+
require_relative 'composite_primary_keys/base'
|
74
|
+
require_relative 'composite_primary_keys/core'
|
75
|
+
require_relative 'composite_primary_keys/composite_arrays'
|
76
|
+
require_relative 'composite_primary_keys/composite_predicates'
|
77
|
+
require_relative 'composite_primary_keys/counter_cache'
|
78
|
+
require_relative 'composite_primary_keys/fixtures'
|
79
|
+
require_relative 'composite_primary_keys/reflection'
|
80
|
+
require_relative 'composite_primary_keys/relation'
|
81
|
+
require_relative 'composite_primary_keys/sanitization'
|
82
|
+
require_relative 'composite_primary_keys/transactions'
|
83
|
+
require_relative 'composite_primary_keys/version'
|
84
|
+
|
85
|
+
require_relative 'composite_primary_keys/associations/association'
|
86
|
+
require_relative 'composite_primary_keys/associations/association_scope'
|
87
|
+
require_relative 'composite_primary_keys/associations/foreign_association'
|
88
|
+
require_relative 'composite_primary_keys/associations/has_many_association'
|
89
|
+
require_relative 'composite_primary_keys/associations/has_many_through_association'
|
90
|
+
require_relative 'composite_primary_keys/associations/join_dependency'
|
91
|
+
require_relative 'composite_primary_keys/associations/preloader/association'
|
92
|
+
require_relative 'composite_primary_keys/associations/collection_association'
|
93
|
+
require_relative 'composite_primary_keys/associations/through_association'
|
94
|
+
|
95
|
+
require_relative 'composite_primary_keys/attribute_methods/primary_key'
|
96
|
+
require_relative 'composite_primary_keys/attribute_methods/read'
|
97
|
+
require_relative 'composite_primary_keys/attribute_methods/write'
|
98
|
+
require_relative 'composite_primary_keys/nested_attributes'
|
99
|
+
|
100
|
+
require_relative 'composite_primary_keys/connection_adapters/abstract/database_statements'
|
101
|
+
require_relative 'composite_primary_keys/connection_adapters/abstract_adapter'
|
102
|
+
require_relative 'composite_primary_keys/connection_adapters/postgresql/database_statements'
|
103
|
+
require_relative 'composite_primary_keys/connection_adapters/sqlserver/database_statements'
|
104
|
+
|
105
|
+
require_relative 'composite_primary_keys/relation/batches'
|
106
|
+
require_relative 'composite_primary_keys/relation/where_clause'
|
107
|
+
require_relative 'composite_primary_keys/relation/calculations'
|
108
|
+
require_relative 'composite_primary_keys/relation/finder_methods'
|
109
|
+
require_relative 'composite_primary_keys/relation/predicate_builder/association_query_value'
|
110
|
+
require_relative 'composite_primary_keys/relation/query_methods'
|
111
|
+
|
112
|
+
require_relative 'composite_primary_keys/validations/uniqueness'
|
113
|
+
|
114
|
+
require_relative 'composite_primary_keys/composite_relation'
|
115
|
+
|
116
|
+
require_relative 'composite_primary_keys/arel/to_sql'
|
117
|
+
require_relative 'composite_primary_keys/arel/sqlserver'
|