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