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.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/History.rdoc +880 -841
  3. data/README.rdoc +180 -179
  4. data/lib/composite_primary_keys/active_model/attribute_assignment.rb +19 -0
  5. data/lib/composite_primary_keys/arel/sqlserver.rb +1 -3
  6. data/lib/composite_primary_keys/associations/association_scope.rb +68 -68
  7. data/lib/composite_primary_keys/associations/join_dependency.rb +103 -103
  8. data/lib/composite_primary_keys/associations/through_association.rb +2 -1
  9. data/lib/composite_primary_keys/attribute_methods/primary_key.rb +13 -0
  10. data/lib/composite_primary_keys/attribute_methods/read.rb +30 -30
  11. data/lib/composite_primary_keys/attribute_methods/write.rb +35 -35
  12. data/lib/composite_primary_keys/attribute_methods.rb +9 -9
  13. data/lib/composite_primary_keys/base.rb +141 -130
  14. data/lib/composite_primary_keys/composite_arrays.rb +0 -8
  15. data/lib/composite_primary_keys/connection_adapters/abstract/database_statements.rb +37 -17
  16. data/lib/composite_primary_keys/connection_adapters/sqlserver/database_statements.rb +44 -23
  17. data/lib/composite_primary_keys/core.rb +48 -48
  18. data/lib/composite_primary_keys/persistence.rb +82 -81
  19. data/lib/composite_primary_keys/reflection.rb +29 -29
  20. data/lib/composite_primary_keys/relation/batches.rb +1 -1
  21. data/lib/composite_primary_keys/relation/calculations.rb +81 -81
  22. data/lib/composite_primary_keys/relation/finder_methods.rb +235 -235
  23. data/lib/composite_primary_keys/relation/predicate_builder/association_query_value.rb +20 -20
  24. data/lib/composite_primary_keys/relation/query_methods.rb +42 -42
  25. data/lib/composite_primary_keys/relation/where_clause.rb +23 -23
  26. data/lib/composite_primary_keys/relation.rb +193 -118
  27. data/lib/composite_primary_keys/version.rb +8 -8
  28. data/lib/composite_primary_keys.rb +117 -118
  29. data/test/abstract_unit.rb +114 -113
  30. data/test/connections/databases.ci.yml +22 -19
  31. data/test/fixtures/article.rb +4 -0
  32. data/test/fixtures/articles.yml +4 -3
  33. data/test/fixtures/comment.rb +1 -3
  34. data/test/fixtures/comments.yml +10 -9
  35. data/test/fixtures/db_definitions/db2-create-tables.sql +112 -126
  36. data/test/fixtures/db_definitions/db2-drop-tables.sql +17 -19
  37. data/test/fixtures/db_definitions/mysql.sql +180 -217
  38. data/test/fixtures/db_definitions/oracle.drop.sql +42 -48
  39. data/test/fixtures/db_definitions/oracle.sql +200 -236
  40. data/test/fixtures/db_definitions/postgresql.sql +183 -220
  41. data/test/fixtures/db_definitions/sqlite.sql +170 -206
  42. data/test/fixtures/db_definitions/sqlserver.sql +176 -212
  43. data/test/fixtures/department.rb +16 -11
  44. data/test/fixtures/departments.yml +15 -15
  45. data/test/fixtures/employees.yml +27 -27
  46. data/test/fixtures/readings.yml +2 -2
  47. data/test/fixtures/restaurants_suburbs.yml +11 -11
  48. data/test/fixtures/streets.yml +16 -16
  49. data/test/fixtures/suburbs.yml +14 -14
  50. data/test/fixtures/user.rb +11 -10
  51. data/test/test_associations.rb +358 -351
  52. data/test/test_attributes.rb +60 -60
  53. data/test/test_calculations.rb +42 -42
  54. data/test/test_create.rb +218 -183
  55. data/test/test_delete.rb +182 -179
  56. data/test/test_exists.rb +39 -39
  57. data/test/test_find.rb +164 -145
  58. data/test/test_habtm.rb +2 -2
  59. data/test/test_ids.rb +112 -116
  60. data/test/test_nested_attributes.rb +67 -124
  61. data/test/test_polymorphic.rb +29 -13
  62. data/test/test_preload.rb +4 -3
  63. data/test/test_serialize.rb +2 -2
  64. data/test/test_update.rb +96 -78
  65. metadata +4 -19
  66. data/test/fixtures/hack.rb +0 -5
  67. data/test/fixtures/hacks.yml +0 -3
  68. data/test/fixtures/pk_called_id.rb +0 -5
  69. data/test/fixtures/pk_called_ids.yml +0 -11
  70. data/test/fixtures/reference_code_using_composite_key_alias.rb +0 -8
  71. data/test/fixtures/reference_code_using_simple_key_alias.rb +0 -8
  72. data/test/fixtures/seat.rb +0 -5
  73. data/test/fixtures/seats.yml +0 -9
  74. data/test/fixtures/topic.rb +0 -6
  75. data/test/fixtures/topic_source.rb +0 -7
  76. data/test/test_aliases.rb +0 -18
  77. data/test/test_enum.rb +0 -21
  78. data/test/test_suite.rb +0 -35
@@ -1,218 +1,181 @@
1
- create table topics (
2
- id int not null auto_increment,
3
- name varchar(50) default null,
4
- feed_size int default null,
5
- primary key (id)
6
- );
7
-
8
- create table topic_sources (
9
- topic_id int not null,
10
- platform varchar(50) not null,
11
- keywords varchar(50) default null,
12
- primary key (topic_id,platform)
13
- );
14
-
15
- create table reference_types (
16
- reference_type_id int not null auto_increment,
17
- type_label varchar(50) default null,
18
- abbreviation varchar(50) default null,
19
- description varchar(50) default null,
20
- primary key (reference_type_id)
21
- );
22
-
23
- create table reference_codes (
24
- reference_type_id int not null,
25
- reference_code int not null,
26
- code_label varchar(50) default null,
27
- abbreviation varchar(50) default null,
28
- description varchar(50) default null,
29
- primary key (reference_type_id, reference_code)
30
- );
31
-
32
- create table products (
33
- id int not null auto_increment,
34
- name varchar(50) default null,
35
- primary key (id)
36
- );
37
-
38
- create table tariffs (
39
- tariff_id int not null,
40
- start_date date not null,
41
- amount integer(11) default null,
42
- created_at datetime,
43
- updated_at datetime,
44
- primary key (tariff_id, start_date)
45
- );
46
-
47
- create table product_tariffs (
48
- product_id int not null,
49
- tariff_id int not null,
50
- tariff_start_date date not null,
51
- primary key (product_id, tariff_id, tariff_start_date)
52
- );
53
-
54
- create table suburbs (
55
- city_id int not null,
56
- suburb_id int not null,
57
- name varchar(50) not null,
58
- primary key (city_id, suburb_id)
59
- );
60
-
61
- create table streets (
62
- id int not null auto_increment,
63
- city_id int not null,
64
- suburb_id int not null,
65
- name varchar(50) not null,
66
- primary key (id)
67
- );
68
-
69
- create table users (
70
- id int not null auto_increment,
71
- name varchar(50) not null,
72
- primary key (id)
73
- );
74
-
75
- create table articles (
76
- id int not null auto_increment,
77
- name varchar(50) not null,
78
- primary key (id)
79
- );
80
-
81
- create table readings (
82
- id int not null auto_increment,
83
- user_id int not null,
84
- article_id int not null,
85
- rating int not null,
86
- primary key (id)
87
- );
88
-
89
- create table groups (
90
- id int not null auto_increment,
91
- name varchar(50) not null,
92
- primary key (id)
93
- );
94
-
95
- create table memberships (
96
- user_id int not null,
97
- group_id int not null,
98
- primary key (user_id,group_id)
99
- );
100
-
101
- create table membership_statuses (
102
- id int not null auto_increment,
103
- user_id int not null,
104
- group_id int not null,
105
- status varchar(50) not null,
106
- primary key (id)
107
- );
108
-
109
- create table departments (
110
- department_id int not null,
111
- location_id int not null,
112
- primary key (department_id, location_id)
113
- );
114
-
115
- create table employees (
116
- id int not null auto_increment,
117
- department_id int default null,
118
- location_id int default null,
119
- name varchar(50) default null,
120
- primary key (id)
121
- );
122
-
123
- create table comments (
124
- id int not null auto_increment,
125
- person_id int default null,
126
- shown int default null,
127
- person_type varchar(100) default null,
128
- hack_id int default null,
129
- primary key (id)
130
- );
131
-
132
- create table hacks (
133
- id int not null auto_increment,
134
- name varchar(50) not null,
135
- primary key (id)
136
- );
137
-
138
- create table restaurants (
139
- franchise_id int not null,
140
- store_id int not null,
141
- name varchar(100),
142
- lock_version int default 0,
143
- primary key (franchise_id, store_id)
144
- );
145
-
146
- create table restaurants_suburbs (
147
- franchise_id int not null,
148
- store_id int not null,
149
- city_id int default null,
150
- suburb_id int default null
151
- );
152
-
153
- create table dorms (
154
- id int not null auto_increment,
155
- primary key(id)
156
- );
157
-
158
- create table rooms (
159
- dorm_id int not null,
160
- room_id int not null,
161
- primary key (dorm_id, room_id)
162
- );
163
-
164
- create table room_attributes (
165
- id int not null auto_increment,
166
- name varchar(50),
167
- primary key(id)
168
- );
169
-
170
- create table room_attribute_assignments (
171
- dorm_id int not null,
172
- room_id int not null,
173
- room_attribute_id int not null
174
- );
175
-
176
- create table students (
177
- id int not null auto_increment,
178
- primary key(id)
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 topics;
2
- drop sequence topics_seq;
3
- drop table topic_sources;
4
- drop table reference_types;
5
- drop sequence reference_types_seq;
6
- drop table reference_codes;
7
- drop table products;
8
- drop sequence products_seq;
9
- drop table tariffs;
10
- drop table product_tariffs;
11
- drop table suburbs;
12
- drop table streets;
13
- drop sequence streets_seq;
14
- drop table users;
15
- drop sequence users_seq;
16
- drop table articles;
17
- drop sequence articles_seq;
18
- drop table readings;
19
- drop sequence readings_seq;
20
- drop table groups;
21
- drop sequence groups_seq;
22
- drop table memberships;
23
- drop table membership_statuses;
24
- drop sequence membership_statuses_seq;
25
- drop table departments;
26
- drop table employees;
27
- drop sequence employees_seq;
28
- drop table comments;
29
- drop sequence comments_seq;
30
- drop table hacks;
31
- drop sequence hacks_seq;
32
- drop table restaurants;
33
- drop table restaurants_suburbs;
34
- drop table dorms;
35
- drop sequence dorms_seq;
36
- drop table rooms;
37
- drop table room_attributes;
38
- drop sequence room_attributes_seq;
39
- drop table room_attribute_assignments;
40
- drop table room_assignments;
41
- drop table students;
42
- drop sequence students_seq;
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;