composite_primary_keys 12.0.4 → 12.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.rdoc +880 -859
- data/README.rdoc +180 -180
- data/lib/composite_primary_keys.rb +117 -118
- data/lib/composite_primary_keys/active_model/attribute_assignment.rb +19 -19
- 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/attribute_methods.rb +9 -9
- 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/base.rb +141 -141
- data/lib/composite_primary_keys/connection_adapters/abstract/database_statements.rb +37 -22
- data/lib/composite_primary_keys/connection_adapters/sqlserver/database_statements.rb +44 -41
- 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.rb +193 -193
- 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/version.rb +8 -8
- data/test/abstract_unit.rb +114 -114
- data/test/connections/databases.ci.yml +22 -19
- data/test/fixtures/db_definitions/db2-create-tables.sql +112 -112
- data/test/fixtures/db_definitions/db2-drop-tables.sql +16 -16
- data/test/fixtures/db_definitions/mysql.sql +180 -180
- data/test/fixtures/db_definitions/oracle.drop.sql +41 -41
- data/test/fixtures/db_definitions/oracle.sql +199 -199
- data/test/fixtures/db_definitions/postgresql.sql +182 -182
- data/test/fixtures/db_definitions/sqlite.sql +169 -169
- data/test/fixtures/db_definitions/sqlserver.sql +176 -176
- data/test/fixtures/department.rb +16 -16
- data/test/fixtures/departments.yml +15 -15
- data/test/fixtures/employees.yml +27 -27
- data/test/fixtures/restaurants_suburbs.yml +10 -10
- data/test/fixtures/streets.yml +16 -16
- data/test/fixtures/suburbs.yml +14 -14
- data/test/fixtures/user.rb +11 -11
- data/test/test_associations.rb +358 -358
- data/test/test_attributes.rb +60 -60
- data/test/test_calculations.rb +42 -42
- data/test/test_create.rb +218 -180
- data/test/test_delete.rb +182 -179
- data/test/test_exists.rb +39 -39
- data/test/test_find.rb +164 -157
- data/test/test_ids.rb +112 -112
- data/test/test_nested_attributes.rb +67 -67
- data/test/test_update.rb +96 -96
- metadata +2 -3
- data/lib/composite_primary_keys/connection_adapters/mysql/database_statements.rb +0 -24
data/README.rdoc
CHANGED
@@ -1,180 +1,180 @@
|
|
1
|
-
= Composite Primary Keys for ActiveRecords
|
2
|
-
|
3
|
-
== Summary
|
4
|
-
|
5
|
-
ActiveRecords 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 12.x is designed to work with ActiveRecord 6.0.x
|
24
|
-
Version 11.x is designed to work with ActiveRecord 5.2.x
|
25
|
-
Version 10.x is designed to work with ActiveRecord 5.1.x
|
26
|
-
Version 9.x is designed to work with ActiveRecord 5.0.x
|
27
|
-
Version 8.x is designed to work with ActiveRecord 4.2.x
|
28
|
-
Version 7.x is designed to work with ActiveRecord 4.1.x
|
29
|
-
Version 6.x is designed to work with ActiveRecord 4.0.x
|
30
|
-
Version 5.x is designed to work with ActiveRecord 3.2.x
|
31
|
-
Version 4.x is designed to work with ActiveRecord 3.1.x
|
32
|
-
|
33
|
-
Run the following command to list available versions:
|
34
|
-
|
35
|
-
gem list composite_primary_keys -ra
|
36
|
-
|
37
|
-
== The basics
|
38
|
-
|
39
|
-
A model with composite primary keys is defined like this:
|
40
|
-
|
41
|
-
class Membership < ActiveRecord::Base
|
42
|
-
self.primary_keys = :user_id, :group_id
|
43
|
-
belongs_to :user
|
44
|
-
belongs_to :group
|
45
|
-
has_many :statuses, :class_name => 'MembershipStatus', :foreign_key => [:user_id, :group_id]
|
46
|
-
end
|
47
|
-
|
48
|
-
Note the addition of the line:
|
49
|
-
|
50
|
-
self.primary_keys = :user_id, :group_id
|
51
|
-
|
52
|
-
|
53
|
-
A model associated with a composite key model is defined like this:
|
54
|
-
|
55
|
-
class MembershipStatus < ActiveRecord::Base
|
56
|
-
belongs_to :membership, :foreign_key => [:user_id, :group_id]
|
57
|
-
end
|
58
|
-
|
59
|
-
That is, associations can include composite keys too. All Rails association types are supported. Nice.
|
60
|
-
|
61
|
-
== Usage
|
62
|
-
|
63
|
-
Once you’ve created your models to specify composite primary keys (such as the Membership class)
|
64
|
-
and associations (such as MembershipStatus#membership), you can use them like any normal model
|
65
|
-
with associations.
|
66
|
-
|
67
|
-
But first, lets check out our primary keys.
|
68
|
-
|
69
|
-
MembershipStatus.primary_key # => "id" # normal single key
|
70
|
-
Membership.primary_key # => [:user_id, :group_id] # composite keys
|
71
|
-
Membership.primary_key.to_s # => "user_id,group_id"
|
72
|
-
|
73
|
-
Now we want to be able to find instances using the same syntax we always use for ActiveRecords…
|
74
|
-
|
75
|
-
MembershipStatus.find(1) # single id returns single instance
|
76
|
-
=> <MembershipStatus:0x392a8c8 @attributes={"id"=>"1", "status"=>"Active"}>
|
77
|
-
|
78
|
-
Membership.find([1,1]) # composite ids returns single instance
|
79
|
-
=> <Membership:0x39218b0 @attributes={"user_id"=>"1", "group_id"=>"1"}>
|
80
|
-
|
81
|
-
Notice the use of an array to specify the composite key values.
|
82
|
-
|
83
|
-
NOTE - API CHANGE. CPK Version 6.x and earlier used to allow composite keys to be listed out
|
84
|
-
like this:
|
85
|
-
|
86
|
-
Membership.find(1,1)
|
87
|
-
|
88
|
-
This usage is no longer supported.
|
89
|
-
|
90
|
-
== Databases
|
91
|
-
|
92
|
-
CPK supports the following databases:
|
93
|
-
|
94
|
-
* PostgreSQL
|
95
|
-
* MySQL
|
96
|
-
* MariaDB
|
97
|
-
* Oracle
|
98
|
-
* DB2
|
99
|
-
* SQLite
|
100
|
-
* SQLServer
|
101
|
-
|
102
|
-
== Tests
|
103
|
-
|
104
|
-
To run tests you first need to install the appropriate gems for the database you want to test. Database gems are
|
105
|
-
divided into the following bundler groups:
|
106
|
-
|
107
|
-
* mysql
|
108
|
-
* oracle
|
109
|
-
* postgresql
|
110
|
-
* sqlite
|
111
|
-
* sqlserver
|
112
|
-
|
113
|
-
Since it is likely you do not have all the above databases installed on your computer, you want to install just the
|
114
|
-
gems for your database. For example, to test postgresql you would install the appropriate gems like this:
|
115
|
-
|
116
|
-
bundler config set --local without "mysql oracle sqlite sqlserver"
|
117
|
-
bundler install
|
118
|
-
|
119
|
-
Once you have installed the appropriate gems, the next step is to create the test database. There is a rake
|
120
|
-
command for each database. Using our example:
|
121
|
-
|
122
|
-
rake postgresql:build_database
|
123
|
-
|
124
|
-
You can also rebuild the database if it already exists using this command:
|
125
|
-
|
126
|
-
rake postgresql:rebuild_database
|
127
|
-
|
128
|
-
To get a list of commands for your database use:
|
129
|
-
|
130
|
-
Rake -T
|
131
|
-
|
132
|
-
Finally, to run tests:
|
133
|
-
|
134
|
-
rake postgresql:test
|
135
|
-
|
136
|
-
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]
|
137
|
-
|
138
|
-
=== DB2
|
139
|
-
|
140
|
-
DB2 is no longer supported due to difficulties in getting the ibm_db2 gem to build. Thus tests
|
141
|
-
have not been run against db2.
|
142
|
-
|
143
|
-
=== MariaDb (mysql)
|
144
|
-
|
145
|
-
MariaDb is fully supported with all tests passing.
|
146
|
-
|
147
|
-
=== Oracle
|
148
|
-
|
149
|
-
Oracle is fully supported with all tests passing.
|
150
|
-
|
151
|
-
=== Postgresql
|
152
|
-
|
153
|
-
Postgresql is fully supported with all tests passing.
|
154
|
-
|
155
|
-
=== Sqlite 3
|
156
|
-
|
157
|
-
The sqlite database is created at the path composite_primary_keys/db. Note you must *first* create the database using the
|
158
|
-
built-in rake task before running tests:
|
159
|
-
|
160
|
-
rake sqlite:build_database
|
161
|
-
|
162
|
-
For sqlite3 to work correctly, you must manually require 'composite_primary_keys/connection_adapters/sqlite3_adapter' after
|
163
|
-
loading the CPK gem.
|
164
|
-
|
165
|
-
=== SqlServer
|
166
|
-
|
167
|
-
SqlServer is partially supported. There are a number of failing tests - patches welcomed.
|
168
|
-
|
169
|
-
== Questions, Discussion and Contributions
|
170
|
-
|
171
|
-
For help please visit https://github.com/composite-primary-keys/composite_primary_keys.
|
172
|
-
|
173
|
-
== Author
|
174
|
-
|
175
|
-
First version was written by Dr Nic Williams.
|
176
|
-
|
177
|
-
Maintained by Charlie Savage
|
178
|
-
|
179
|
-
Contributions by many!
|
180
|
-
|
1
|
+
= Composite Primary Keys for ActiveRecords
|
2
|
+
|
3
|
+
== Summary
|
4
|
+
|
5
|
+
ActiveRecords 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 12.x is designed to work with ActiveRecord 6.0.x
|
24
|
+
Version 11.x is designed to work with ActiveRecord 5.2.x
|
25
|
+
Version 10.x is designed to work with ActiveRecord 5.1.x
|
26
|
+
Version 9.x is designed to work with ActiveRecord 5.0.x
|
27
|
+
Version 8.x is designed to work with ActiveRecord 4.2.x
|
28
|
+
Version 7.x is designed to work with ActiveRecord 4.1.x
|
29
|
+
Version 6.x is designed to work with ActiveRecord 4.0.x
|
30
|
+
Version 5.x is designed to work with ActiveRecord 3.2.x
|
31
|
+
Version 4.x is designed to work with ActiveRecord 3.1.x
|
32
|
+
|
33
|
+
Run the following command to list available versions:
|
34
|
+
|
35
|
+
gem list composite_primary_keys -ra
|
36
|
+
|
37
|
+
== The basics
|
38
|
+
|
39
|
+
A model with composite primary keys is defined like this:
|
40
|
+
|
41
|
+
class Membership < ActiveRecord::Base
|
42
|
+
self.primary_keys = :user_id, :group_id
|
43
|
+
belongs_to :user
|
44
|
+
belongs_to :group
|
45
|
+
has_many :statuses, :class_name => 'MembershipStatus', :foreign_key => [:user_id, :group_id]
|
46
|
+
end
|
47
|
+
|
48
|
+
Note the addition of the line:
|
49
|
+
|
50
|
+
self.primary_keys = :user_id, :group_id
|
51
|
+
|
52
|
+
|
53
|
+
A model associated with a composite key model is defined like this:
|
54
|
+
|
55
|
+
class MembershipStatus < ActiveRecord::Base
|
56
|
+
belongs_to :membership, :foreign_key => [:user_id, :group_id]
|
57
|
+
end
|
58
|
+
|
59
|
+
That is, associations can include composite keys too. All Rails association types are supported. Nice.
|
60
|
+
|
61
|
+
== Usage
|
62
|
+
|
63
|
+
Once you’ve created your models to specify composite primary keys (such as the Membership class)
|
64
|
+
and associations (such as MembershipStatus#membership), you can use them like any normal model
|
65
|
+
with associations.
|
66
|
+
|
67
|
+
But first, lets check out our primary keys.
|
68
|
+
|
69
|
+
MembershipStatus.primary_key # => "id" # normal single key
|
70
|
+
Membership.primary_key # => [:user_id, :group_id] # composite keys
|
71
|
+
Membership.primary_key.to_s # => "user_id,group_id"
|
72
|
+
|
73
|
+
Now we want to be able to find instances using the same syntax we always use for ActiveRecords…
|
74
|
+
|
75
|
+
MembershipStatus.find(1) # single id returns single instance
|
76
|
+
=> <MembershipStatus:0x392a8c8 @attributes={"id"=>"1", "status"=>"Active"}>
|
77
|
+
|
78
|
+
Membership.find([1,1]) # composite ids returns single instance
|
79
|
+
=> <Membership:0x39218b0 @attributes={"user_id"=>"1", "group_id"=>"1"}>
|
80
|
+
|
81
|
+
Notice the use of an array to specify the composite key values.
|
82
|
+
|
83
|
+
NOTE - API CHANGE. CPK Version 6.x and earlier used to allow composite keys to be listed out
|
84
|
+
like this:
|
85
|
+
|
86
|
+
Membership.find(1,1)
|
87
|
+
|
88
|
+
This usage is no longer supported.
|
89
|
+
|
90
|
+
== Databases
|
91
|
+
|
92
|
+
CPK supports the following databases:
|
93
|
+
|
94
|
+
* PostgreSQL
|
95
|
+
* MySQL
|
96
|
+
* MariaDB
|
97
|
+
* Oracle
|
98
|
+
* DB2
|
99
|
+
* SQLite
|
100
|
+
* SQLServer
|
101
|
+
|
102
|
+
== Tests
|
103
|
+
|
104
|
+
To run tests you first need to install the appropriate gems for the database you want to test. Database gems are
|
105
|
+
divided into the following bundler groups:
|
106
|
+
|
107
|
+
* mysql
|
108
|
+
* oracle
|
109
|
+
* postgresql
|
110
|
+
* sqlite
|
111
|
+
* sqlserver
|
112
|
+
|
113
|
+
Since it is likely you do not have all the above databases installed on your computer, you want to install just the
|
114
|
+
gems for your database. For example, to test postgresql you would install the appropriate gems like this:
|
115
|
+
|
116
|
+
bundler config set --local without "mysql oracle sqlite sqlserver"
|
117
|
+
bundler install
|
118
|
+
|
119
|
+
Once you have installed the appropriate gems, the next step is to create the test database. There is a rake
|
120
|
+
command for each database. Using our example:
|
121
|
+
|
122
|
+
rake postgresql:build_database
|
123
|
+
|
124
|
+
You can also rebuild the database if it already exists using this command:
|
125
|
+
|
126
|
+
rake postgresql:rebuild_database
|
127
|
+
|
128
|
+
To get a list of commands for your database use:
|
129
|
+
|
130
|
+
Rake -T
|
131
|
+
|
132
|
+
Finally, to run tests:
|
133
|
+
|
134
|
+
rake postgresql:test
|
135
|
+
|
136
|
+
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]
|
137
|
+
|
138
|
+
=== DB2
|
139
|
+
|
140
|
+
DB2 is no longer supported due to difficulties in getting the ibm_db2 gem to build. Thus tests
|
141
|
+
have not been run against db2.
|
142
|
+
|
143
|
+
=== MariaDb (mysql)
|
144
|
+
|
145
|
+
MariaDb is fully supported with all tests passing.
|
146
|
+
|
147
|
+
=== Oracle
|
148
|
+
|
149
|
+
Oracle is fully supported with all tests passing.
|
150
|
+
|
151
|
+
=== Postgresql
|
152
|
+
|
153
|
+
Postgresql is fully supported with all tests passing.
|
154
|
+
|
155
|
+
=== Sqlite 3
|
156
|
+
|
157
|
+
The sqlite database is created at the path composite_primary_keys/db. Note you must *first* create the database using the
|
158
|
+
built-in rake task before running tests:
|
159
|
+
|
160
|
+
rake sqlite:build_database
|
161
|
+
|
162
|
+
For sqlite3 to work correctly, you must manually require 'composite_primary_keys/connection_adapters/sqlite3_adapter' after
|
163
|
+
loading the CPK gem.
|
164
|
+
|
165
|
+
=== SqlServer
|
166
|
+
|
167
|
+
SqlServer is partially supported. There are a number of failing tests - patches welcomed.
|
168
|
+
|
169
|
+
== Questions, Discussion and Contributions
|
170
|
+
|
171
|
+
For help please visit https://github.com/composite-primary-keys/composite_primary_keys.
|
172
|
+
|
173
|
+
== Author
|
174
|
+
|
175
|
+
First version was written by Dr Nic Williams.
|
176
|
+
|
177
|
+
Maintained by Charlie Savage
|
178
|
+
|
179
|
+
Contributions by many!
|
180
|
+
|
@@ -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
|
-
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/
|
103
|
-
require_relative 'composite_primary_keys/connection_adapters/
|
104
|
-
|
105
|
-
|
106
|
-
require_relative 'composite_primary_keys/relation/
|
107
|
-
require_relative 'composite_primary_keys/relation/
|
108
|
-
require_relative 'composite_primary_keys/relation/
|
109
|
-
require_relative 'composite_primary_keys/relation/
|
110
|
-
require_relative 'composite_primary_keys/relation/
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
require_relative 'composite_primary_keys/arel/
|
118
|
-
require_relative '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'
|