composite_primary_keys 12.0.9 → 13.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/History.rdoc +883 -877
  3. data/README.rdoc +181 -180
  4. data/lib/composite_primary_keys.rb +119 -117
  5. data/lib/composite_primary_keys/active_model/attribute_assignment.rb +19 -19
  6. data/lib/composite_primary_keys/associations/association_scope.rb +66 -68
  7. data/lib/composite_primary_keys/associations/join_dependency.rb +118 -103
  8. data/lib/composite_primary_keys/attribute_methods.rb +21 -9
  9. data/lib/composite_primary_keys/attribute_methods/primary_key.rb +0 -2
  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/base.rb +141 -141
  13. data/lib/composite_primary_keys/connection_adapters/abstract/database_statements.rb +37 -37
  14. data/lib/composite_primary_keys/connection_adapters/sqlserver/database_statements.rb +44 -44
  15. data/lib/composite_primary_keys/core.rb +48 -48
  16. data/lib/composite_primary_keys/nested_attributes.rb +1 -1
  17. data/lib/composite_primary_keys/persistence.rb +82 -81
  18. data/lib/composite_primary_keys/reflection.rb +91 -29
  19. data/lib/composite_primary_keys/relation.rb +197 -193
  20. data/lib/composite_primary_keys/relation/batches.rb +15 -7
  21. data/lib/composite_primary_keys/relation/calculations.rb +104 -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 +39 -20
  24. data/lib/composite_primary_keys/relation/query_methods.rb +42 -42
  25. data/lib/composite_primary_keys/relation/where_clause.rb +18 -23
  26. data/lib/composite_primary_keys/table_metadata.rb +11 -0
  27. data/lib/composite_primary_keys/version.rb +8 -8
  28. data/test/abstract_unit.rb +114 -114
  29. data/test/connections/databases.ci.yml +22 -22
  30. data/test/fixtures/db_definitions/db2-create-tables.sql +112 -112
  31. data/test/fixtures/db_definitions/db2-drop-tables.sql +16 -16
  32. data/test/fixtures/db_definitions/mysql.sql +180 -180
  33. data/test/fixtures/db_definitions/oracle.drop.sql +41 -41
  34. data/test/fixtures/db_definitions/oracle.sql +199 -199
  35. data/test/fixtures/db_definitions/postgresql.sql +182 -182
  36. data/test/fixtures/db_definitions/sqlite.sql +169 -169
  37. data/test/fixtures/db_definitions/sqlserver.sql +176 -176
  38. data/test/fixtures/department.rb +16 -16
  39. data/test/fixtures/departments.yml +19 -15
  40. data/test/fixtures/employees.yml +33 -28
  41. data/test/fixtures/restaurants_suburbs.yml +10 -10
  42. data/test/fixtures/streets.yml +16 -16
  43. data/test/fixtures/suburbs.yml +14 -14
  44. data/test/fixtures/user.rb +11 -11
  45. data/test/test_associations.rb +364 -358
  46. data/test/test_attributes.rb +75 -60
  47. data/test/test_calculations.rb +49 -42
  48. data/test/test_create.rb +218 -206
  49. data/test/test_delete.rb +182 -179
  50. data/test/test_exists.rb +39 -39
  51. data/test/test_find.rb +170 -164
  52. data/test/test_ids.rb +112 -112
  53. data/test/test_nested_attributes.rb +67 -67
  54. data/test/test_update.rb +96 -96
  55. metadata +12 -11
@@ -1,42 +1,42 @@
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;
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
42
  drop table employees_groups;
@@ -1,200 +1,200 @@
1
- create sequence reference_types_seq start with 1000;
2
-
3
- create table reference_types (
4
- reference_type_id number(11) primary key,
5
- type_label varchar(50) default null,
6
- abbreviation varchar(50) default null,
7
- description varchar(50) default null
8
- );
9
-
10
- create table reference_codes (
11
- reference_type_id number(11),
12
- reference_code number(11),
13
- code_label varchar(50) default null,
14
- abbreviation varchar(50) default null,
15
- description varchar(50) default null
16
- );
17
-
18
- create sequence products_seq start with 1000;
19
-
20
- create table products (
21
- id number(11) primary key,
22
- name varchar(50) default null
23
- );
24
-
25
- create table tariffs (
26
- tariff_id number(11),
27
- start_date date,
28
- amount number(11) default null,
29
- created_at timestamp,
30
- updated_at timestamp,
31
- constraint tariffs_pk primary key (tariff_id, start_date)
32
- );
33
-
34
- create table product_tariffs (
35
- product_id number(11),
36
- tariff_id number(11),
37
- tariff_start_date date,
38
- constraint product_tariffs_pk primary key (product_id, tariff_id, tariff_start_date)
39
- );
40
-
41
- create sequence suburbs_city_id_seq start with 1000;
42
-
43
- create table suburbs (
44
- city_id number(11) default suburbs_city_id_seq.nextval not null,
45
- suburb_id number(11) not null,
46
- name varchar(50) not null,
47
- constraint suburbs_pk primary key (city_id, suburb_id)
48
- );
49
-
50
- create sequence streets_seq start with 1000;
51
-
52
- create table streets (
53
- id number(11) primary key,
54
- city_id number(11) not null,
55
- suburb_id number(11) not null,
56
- name varchar(50) not null
57
- );
58
-
59
- create sequence users_seq start with 1000;
60
-
61
- create table users (
62
- id number(11) primary key,
63
- name varchar(50) not null
64
- );
65
-
66
- create sequence articles_seq start with 1000;
67
-
68
- create table articles (
69
- id number(11) primary key,
70
- name varchar(50) not null
71
- );
72
-
73
- create sequence readings_seq start with 1000;
74
-
75
- create table readings (
76
- id number(11) primary key,
77
- user_id number(11) not null,
78
- article_id number(11) not null,
79
- rating number(11) not null
80
- );
81
-
82
- create sequence groups_seq start with 1000;
83
-
84
- create table groups (
85
- id number(11) primary key,
86
- name varchar(50) not null
87
- );
88
-
89
- create table memberships (
90
- user_id number(11) not null,
91
- group_id number(11) not null,
92
- constraint memberships_pk primary key (user_id, group_id)
93
- );
94
-
95
- create sequence membership_statuses_seq start with 1000;
96
-
97
- create table membership_statuses (
98
- id number(11) primary key,
99
- user_id number(11) not null,
100
- group_id number(11) not null,
101
- status varchar(50) not null
102
- );
103
-
104
- create sequence departments_seq start with 1000;
105
-
106
- create table departments (
107
- id number(11) not null,
108
- location_id number(11) not null,
109
- constraint departments_pk primary key (id, location_id)
110
- );
111
-
112
- create sequence employees_seq start with 1000;
113
-
114
- create table employees (
115
- id number(11) not null primary key,
116
- department_id number(11) default null,
117
- location_id number(11) default null,
118
- name varchar(50) not null
119
- );
120
-
121
- create sequence comments_seq start with 1000;
122
-
123
- create table comments (
124
- id number(11) not null primary key,
125
- article_id number(11) not null,
126
- person_id number(11) not null,
127
- person_type varchar(100) not null
128
- );
129
-
130
- create table restaurants (
131
- franchise_id number(11) not null,
132
- store_id number(11) not null,
133
- name varchar(100),
134
- lock_version number(11) default 0,
135
- constraint restaurants_pk primary key (franchise_id, store_id)
136
- );
137
-
138
- create table restaurants_suburbs (
139
- franchise_id number(11) not null,
140
- store_id number(11) not null,
141
- city_id number(11) not null,
142
- suburb_id number(11) not null
143
- );
144
-
145
- create sequence dorms_seq start with 1000;
146
-
147
- create table dorms (
148
- id number(11) not null,
149
- constraint dorms_pk primary key (id)
150
- );
151
-
152
- create table rooms (
153
- dorm_id number(11) not null,
154
- room_id number(11) not null,
155
- constraint rooms_pk primary key (dorm_id, room_id)
156
- );
157
-
158
- create sequence room_attributes_seq start with 1000;
159
-
160
- create table room_attributes (
161
- id number(11) not null,
162
- name varchar(50),
163
- constraint room_attributes_pk primary key (id)
164
- );
165
-
166
- create table room_attribute_assignments (
167
- dorm_id number(11) not null,
168
- room_id number(11) not null,
169
- room_attribute_id number(11) not null
170
- );
171
-
172
- create sequence students_seq start with 1000;
173
-
174
- create table students (
175
- id number(11) not null,
176
- constraint students_pk primary key (id)
177
- );
178
-
179
- create table room_assignments (
180
- student_id number(11) not null,
181
- dorm_id number(11) not null,
182
- room_id number(11) not null
183
- );
184
-
185
- create table capitols (
186
- country varchar(100) not null,
187
- city varchar(100) not null,
188
- primary key (country, city)
189
- );
190
-
191
- create table products_restaurants (
192
- product_id number(11) not null,
193
- franchise_id number(11) not null,
194
- store_id number(11) not null
195
- );
196
-
197
- create table employees_groups (
198
- employee_id int not null,
199
- group_id int not null
1
+ create sequence reference_types_seq start with 1000;
2
+
3
+ create table reference_types (
4
+ reference_type_id number(11) primary key,
5
+ type_label varchar(50) default null,
6
+ abbreviation varchar(50) default null,
7
+ description varchar(50) default null
8
+ );
9
+
10
+ create table reference_codes (
11
+ reference_type_id number(11),
12
+ reference_code number(11),
13
+ code_label varchar(50) default null,
14
+ abbreviation varchar(50) default null,
15
+ description varchar(50) default null
16
+ );
17
+
18
+ create sequence products_seq start with 1000;
19
+
20
+ create table products (
21
+ id number(11) primary key,
22
+ name varchar(50) default null
23
+ );
24
+
25
+ create table tariffs (
26
+ tariff_id number(11),
27
+ start_date date,
28
+ amount number(11) default null,
29
+ created_at timestamp,
30
+ updated_at timestamp,
31
+ constraint tariffs_pk primary key (tariff_id, start_date)
32
+ );
33
+
34
+ create table product_tariffs (
35
+ product_id number(11),
36
+ tariff_id number(11),
37
+ tariff_start_date date,
38
+ constraint product_tariffs_pk primary key (product_id, tariff_id, tariff_start_date)
39
+ );
40
+
41
+ create sequence suburbs_city_id_seq start with 1000;
42
+
43
+ create table suburbs (
44
+ city_id number(11) default suburbs_city_id_seq.nextval not null,
45
+ suburb_id number(11) not null,
46
+ name varchar(50) not null,
47
+ constraint suburbs_pk primary key (city_id, suburb_id)
48
+ );
49
+
50
+ create sequence streets_seq start with 1000;
51
+
52
+ create table streets (
53
+ id number(11) primary key,
54
+ city_id number(11) not null,
55
+ suburb_id number(11) not null,
56
+ name varchar(50) not null
57
+ );
58
+
59
+ create sequence users_seq start with 1000;
60
+
61
+ create table users (
62
+ id number(11) primary key,
63
+ name varchar(50) not null
64
+ );
65
+
66
+ create sequence articles_seq start with 1000;
67
+
68
+ create table articles (
69
+ id number(11) primary key,
70
+ name varchar(50) not null
71
+ );
72
+
73
+ create sequence readings_seq start with 1000;
74
+
75
+ create table readings (
76
+ id number(11) primary key,
77
+ user_id number(11) not null,
78
+ article_id number(11) not null,
79
+ rating number(11) not null
80
+ );
81
+
82
+ create sequence groups_seq start with 1000;
83
+
84
+ create table groups (
85
+ id number(11) primary key,
86
+ name varchar(50) not null
87
+ );
88
+
89
+ create table memberships (
90
+ user_id number(11) not null,
91
+ group_id number(11) not null,
92
+ constraint memberships_pk primary key (user_id, group_id)
93
+ );
94
+
95
+ create sequence membership_statuses_seq start with 1000;
96
+
97
+ create table membership_statuses (
98
+ id number(11) primary key,
99
+ user_id number(11) not null,
100
+ group_id number(11) not null,
101
+ status varchar(50) not null
102
+ );
103
+
104
+ create sequence departments_seq start with 1000;
105
+
106
+ create table departments (
107
+ id number(11) not null,
108
+ location_id number(11) not null,
109
+ constraint departments_pk primary key (id, location_id)
110
+ );
111
+
112
+ create sequence employees_seq start with 1000;
113
+
114
+ create table employees (
115
+ id number(11) not null primary key,
116
+ department_id number(11) default null,
117
+ location_id number(11) default null,
118
+ name varchar(50) not null
119
+ );
120
+
121
+ create sequence comments_seq start with 1000;
122
+
123
+ create table comments (
124
+ id number(11) not null primary key,
125
+ article_id number(11) not null,
126
+ person_id number(11) not null,
127
+ person_type varchar(100) not null
128
+ );
129
+
130
+ create table restaurants (
131
+ franchise_id number(11) not null,
132
+ store_id number(11) not null,
133
+ name varchar(100),
134
+ lock_version number(11) default 0,
135
+ constraint restaurants_pk primary key (franchise_id, store_id)
136
+ );
137
+
138
+ create table restaurants_suburbs (
139
+ franchise_id number(11) not null,
140
+ store_id number(11) not null,
141
+ city_id number(11) not null,
142
+ suburb_id number(11) not null
143
+ );
144
+
145
+ create sequence dorms_seq start with 1000;
146
+
147
+ create table dorms (
148
+ id number(11) not null,
149
+ constraint dorms_pk primary key (id)
150
+ );
151
+
152
+ create table rooms (
153
+ dorm_id number(11) not null,
154
+ room_id number(11) not null,
155
+ constraint rooms_pk primary key (dorm_id, room_id)
156
+ );
157
+
158
+ create sequence room_attributes_seq start with 1000;
159
+
160
+ create table room_attributes (
161
+ id number(11) not null,
162
+ name varchar(50),
163
+ constraint room_attributes_pk primary key (id)
164
+ );
165
+
166
+ create table room_attribute_assignments (
167
+ dorm_id number(11) not null,
168
+ room_id number(11) not null,
169
+ room_attribute_id number(11) not null
170
+ );
171
+
172
+ create sequence students_seq start with 1000;
173
+
174
+ create table students (
175
+ id number(11) not null,
176
+ constraint students_pk primary key (id)
177
+ );
178
+
179
+ create table room_assignments (
180
+ student_id number(11) not null,
181
+ dorm_id number(11) not null,
182
+ room_id number(11) not null
183
+ );
184
+
185
+ create table capitols (
186
+ country varchar(100) not null,
187
+ city varchar(100) not null,
188
+ primary key (country, city)
189
+ );
190
+
191
+ create table products_restaurants (
192
+ product_id number(11) not null,
193
+ franchise_id number(11) not null,
194
+ store_id number(11) not null
195
+ );
196
+
197
+ create table employees_groups (
198
+ employee_id int not null,
199
+ group_id int not null
200
200
  );