composite_primary_keys 12.0.2 → 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 -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,218 +1,181 @@
|
|
1
|
-
create table
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
primary key (
|
45
|
-
);
|
46
|
-
|
47
|
-
create table
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
)
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
name varchar(50) not null,
|
58
|
-
primary key (
|
59
|
-
);
|
60
|
-
|
61
|
-
create table
|
62
|
-
id int not null auto_increment,
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
primary key (id)
|
73
|
-
);
|
74
|
-
|
75
|
-
create table
|
76
|
-
id int not null auto_increment,
|
77
|
-
name varchar(50) not null,
|
78
|
-
primary key (id)
|
79
|
-
);
|
80
|
-
|
81
|
-
create table
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
primary key (id)
|
93
|
-
);
|
94
|
-
|
95
|
-
create table
|
96
|
-
|
97
|
-
|
98
|
-
primary key
|
99
|
-
);
|
100
|
-
|
101
|
-
create table
|
102
|
-
id int not null auto_increment,
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
primary key (id)
|
107
|
-
);
|
108
|
-
|
109
|
-
create table
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
)
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
);
|
131
|
-
|
132
|
-
create table
|
133
|
-
id int not null auto_increment,
|
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
|
-
create table room_assignments (
|
182
|
-
student_id int not null,
|
183
|
-
dorm_id int not null,
|
184
|
-
room_id int not null
|
185
|
-
);
|
186
|
-
|
187
|
-
create table seats (
|
188
|
-
flight_number int not null,
|
189
|
-
seat int not null,
|
190
|
-
customer int,
|
191
|
-
primary key (flight_number, seat)
|
192
|
-
);
|
193
|
-
|
194
|
-
create table capitols (
|
195
|
-
country varchar(100) not null,
|
196
|
-
city varchar(100) not null,
|
197
|
-
primary key (country, city)
|
198
|
-
);
|
199
|
-
|
200
|
-
create table products_restaurants (
|
201
|
-
product_id int not null,
|
202
|
-
franchise_id int default null,
|
203
|
-
store_id int default null
|
204
|
-
);
|
205
|
-
|
206
|
-
create table employees_groups (
|
207
|
-
employee_id int not null,
|
208
|
-
group_id int not null
|
209
|
-
);
|
210
|
-
|
211
|
-
create table pk_called_ids (
|
212
|
-
id integer not null,
|
213
|
-
reference_code int not null,
|
214
|
-
code_label varchar(50) default null,
|
215
|
-
abbreviation varchar(50) default null,
|
216
|
-
description varchar(50) default null,
|
217
|
-
primary key (id, reference_code)
|
1
|
+
create table reference_types (
|
2
|
+
reference_type_id int not null auto_increment,
|
3
|
+
type_label varchar(50) default null,
|
4
|
+
abbreviation varchar(50) default null,
|
5
|
+
description varchar(50) default null,
|
6
|
+
primary key (reference_type_id)
|
7
|
+
);
|
8
|
+
|
9
|
+
create table reference_codes (
|
10
|
+
reference_type_id int not null,
|
11
|
+
reference_code int not null,
|
12
|
+
code_label varchar(50) default null,
|
13
|
+
abbreviation varchar(50) default null,
|
14
|
+
description varchar(50) default null,
|
15
|
+
primary key (reference_type_id, reference_code)
|
16
|
+
);
|
17
|
+
|
18
|
+
create table products (
|
19
|
+
id int not null auto_increment,
|
20
|
+
name varchar(50) default null,
|
21
|
+
primary key (id)
|
22
|
+
);
|
23
|
+
|
24
|
+
create table tariffs (
|
25
|
+
tariff_id int not null,
|
26
|
+
start_date date not null,
|
27
|
+
amount integer(11) default null,
|
28
|
+
created_at datetime,
|
29
|
+
updated_at datetime,
|
30
|
+
primary key (tariff_id, start_date)
|
31
|
+
);
|
32
|
+
|
33
|
+
create table product_tariffs (
|
34
|
+
product_id int not null,
|
35
|
+
tariff_id int not null,
|
36
|
+
tariff_start_date date not null,
|
37
|
+
primary key (product_id, tariff_id, tariff_start_date)
|
38
|
+
);
|
39
|
+
|
40
|
+
create table suburbs (
|
41
|
+
city_id int not null auto_increment,
|
42
|
+
suburb_id int not null,
|
43
|
+
name varchar(50) not null,
|
44
|
+
primary key (city_id, suburb_id)
|
45
|
+
);
|
46
|
+
|
47
|
+
create table streets (
|
48
|
+
id int not null auto_increment,
|
49
|
+
city_id int not null,
|
50
|
+
suburb_id int not null,
|
51
|
+
name varchar(50) not null,
|
52
|
+
primary key (id)
|
53
|
+
);
|
54
|
+
|
55
|
+
create table users (
|
56
|
+
id int not null auto_increment,
|
57
|
+
name varchar(50) not null,
|
58
|
+
primary key (id)
|
59
|
+
);
|
60
|
+
|
61
|
+
create table articles (
|
62
|
+
id int not null auto_increment,
|
63
|
+
name varchar(50) not null,
|
64
|
+
primary key (id)
|
65
|
+
);
|
66
|
+
|
67
|
+
create table readings (
|
68
|
+
id int not null auto_increment,
|
69
|
+
user_id int not null,
|
70
|
+
article_id int not null,
|
71
|
+
rating int not null,
|
72
|
+
primary key (id)
|
73
|
+
);
|
74
|
+
|
75
|
+
create table `groups` (
|
76
|
+
id int not null auto_increment,
|
77
|
+
name varchar(50) not null,
|
78
|
+
primary key (id)
|
79
|
+
);
|
80
|
+
|
81
|
+
create table memberships (
|
82
|
+
user_id int not null,
|
83
|
+
group_id int not null,
|
84
|
+
primary key (user_id,group_id)
|
85
|
+
);
|
86
|
+
|
87
|
+
create table membership_statuses (
|
88
|
+
id int not null auto_increment,
|
89
|
+
user_id int not null,
|
90
|
+
group_id int not null,
|
91
|
+
status varchar(50) not null,
|
92
|
+
primary key (id)
|
93
|
+
);
|
94
|
+
|
95
|
+
create table departments (
|
96
|
+
id int not null auto_increment,
|
97
|
+
location_id int not null,
|
98
|
+
primary key (id, location_id)
|
99
|
+
);
|
100
|
+
|
101
|
+
create table employees (
|
102
|
+
id int not null auto_increment,
|
103
|
+
department_id int default null,
|
104
|
+
location_id int default null,
|
105
|
+
name varchar(50) default null,
|
106
|
+
primary key (id)
|
107
|
+
);
|
108
|
+
|
109
|
+
create table comments (
|
110
|
+
id int not null auto_increment,
|
111
|
+
article_id int not null,
|
112
|
+
person_id int not null,
|
113
|
+
person_type varchar(100) not null,
|
114
|
+
primary key (id)
|
115
|
+
);
|
116
|
+
|
117
|
+
create table restaurants (
|
118
|
+
franchise_id int not null,
|
119
|
+
store_id int not null,
|
120
|
+
name varchar(100),
|
121
|
+
lock_version int default 0,
|
122
|
+
primary key (franchise_id, store_id)
|
123
|
+
);
|
124
|
+
|
125
|
+
create table restaurants_suburbs (
|
126
|
+
franchise_id int not null,
|
127
|
+
store_id int not null,
|
128
|
+
city_id int default null,
|
129
|
+
suburb_id int default null
|
130
|
+
);
|
131
|
+
|
132
|
+
create table dorms (
|
133
|
+
id int not null auto_increment,
|
134
|
+
primary key(id)
|
135
|
+
);
|
136
|
+
|
137
|
+
create table rooms (
|
138
|
+
dorm_id int not null,
|
139
|
+
room_id int not null,
|
140
|
+
primary key (dorm_id, room_id)
|
141
|
+
);
|
142
|
+
|
143
|
+
create table room_attributes (
|
144
|
+
id int not null auto_increment,
|
145
|
+
name varchar(50),
|
146
|
+
primary key(id)
|
147
|
+
);
|
148
|
+
|
149
|
+
create table room_attribute_assignments (
|
150
|
+
dorm_id int not null,
|
151
|
+
room_id int not null,
|
152
|
+
room_attribute_id int not null
|
153
|
+
);
|
154
|
+
|
155
|
+
create table students (
|
156
|
+
id int not null auto_increment,
|
157
|
+
primary key(id)
|
158
|
+
);
|
159
|
+
|
160
|
+
create table room_assignments (
|
161
|
+
student_id int not null,
|
162
|
+
dorm_id int not null,
|
163
|
+
room_id int not null
|
164
|
+
);
|
165
|
+
|
166
|
+
create table capitols (
|
167
|
+
country varchar(100) not null,
|
168
|
+
city varchar(100) not null,
|
169
|
+
primary key (country, city)
|
170
|
+
);
|
171
|
+
|
172
|
+
create table products_restaurants (
|
173
|
+
product_id int not null,
|
174
|
+
franchise_id int default null,
|
175
|
+
store_id int default null
|
176
|
+
);
|
177
|
+
|
178
|
+
create table employees_groups (
|
179
|
+
employee_id int not null,
|
180
|
+
group_id int not null
|
218
181
|
);
|
@@ -1,48 +1,42 @@
|
|
1
|
-
drop table
|
2
|
-
drop sequence
|
3
|
-
drop table
|
4
|
-
drop table
|
5
|
-
drop sequence
|
6
|
-
drop table
|
7
|
-
drop table
|
8
|
-
drop
|
9
|
-
drop
|
10
|
-
drop table
|
11
|
-
drop
|
12
|
-
drop table
|
13
|
-
drop sequence
|
14
|
-
drop table
|
15
|
-
drop sequence
|
16
|
-
drop table
|
17
|
-
drop sequence
|
18
|
-
drop table
|
19
|
-
drop sequence
|
20
|
-
drop table
|
21
|
-
drop
|
22
|
-
drop
|
23
|
-
drop table
|
24
|
-
drop sequence
|
25
|
-
drop table
|
26
|
-
drop
|
27
|
-
drop
|
28
|
-
drop
|
29
|
-
drop
|
30
|
-
drop table
|
31
|
-
drop
|
32
|
-
drop
|
33
|
-
drop table
|
34
|
-
drop table
|
35
|
-
drop sequence
|
36
|
-
drop table
|
37
|
-
drop table
|
38
|
-
drop
|
39
|
-
drop
|
40
|
-
drop table
|
41
|
-
drop table
|
42
|
-
drop
|
43
|
-
drop table seats;
|
44
|
-
drop table capitols;
|
45
|
-
drop table products_restaurants;
|
46
|
-
drop table employees_groups;
|
47
|
-
drop table pk_called_ids;
|
48
|
-
drop sequence pk_called_ids_seq;
|
1
|
+
drop table reference_types;
|
2
|
+
drop sequence reference_types_seq;
|
3
|
+
drop table reference_codes;
|
4
|
+
drop table products;
|
5
|
+
drop sequence products_seq;
|
6
|
+
drop table tariffs;
|
7
|
+
drop table product_tariffs;
|
8
|
+
drop table suburbs;
|
9
|
+
drop sequence suburbs_city_id_seq;
|
10
|
+
drop table streets;
|
11
|
+
drop sequence streets_seq;
|
12
|
+
drop table users;
|
13
|
+
drop sequence users_seq;
|
14
|
+
drop table articles;
|
15
|
+
drop sequence articles_seq;
|
16
|
+
drop table readings;
|
17
|
+
drop sequence readings_seq;
|
18
|
+
drop table groups;
|
19
|
+
drop sequence groups_seq;
|
20
|
+
drop table memberships;
|
21
|
+
drop table membership_statuses;
|
22
|
+
drop sequence membership_statuses_seq;
|
23
|
+
drop table departments;
|
24
|
+
drop sequence departments_seq;
|
25
|
+
drop table employees;
|
26
|
+
drop sequence employees_seq;
|
27
|
+
drop table comments;
|
28
|
+
drop sequence comments_seq;
|
29
|
+
drop table restaurants;
|
30
|
+
drop table restaurants_suburbs;
|
31
|
+
drop table dorms;
|
32
|
+
drop sequence dorms_seq;
|
33
|
+
drop table rooms;
|
34
|
+
drop table room_attributes;
|
35
|
+
drop sequence room_attributes_seq;
|
36
|
+
drop table room_attribute_assignments;
|
37
|
+
drop table room_assignments;
|
38
|
+
drop table students;
|
39
|
+
drop sequence students_seq;
|
40
|
+
drop table capitols;
|
41
|
+
drop table products_restaurants;
|
42
|
+
drop table employees_groups;
|