composite_primary_keys 8.1.0 → 8.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/History.rdoc +642 -625
  3. data/README.rdoc +5 -2
  4. data/lib/composite_primary_keys.rb +115 -115
  5. data/lib/composite_primary_keys/associations/association.rb +23 -23
  6. data/lib/composite_primary_keys/associations/association_scope.rb +73 -73
  7. data/lib/composite_primary_keys/associations/collection_association.rb +14 -14
  8. data/lib/composite_primary_keys/associations/has_many_association.rb +69 -69
  9. data/lib/composite_primary_keys/associations/join_dependency.rb +87 -87
  10. data/lib/composite_primary_keys/associations/preloader/association.rb +90 -90
  11. data/lib/composite_primary_keys/associations/singular_association.rb +18 -18
  12. data/lib/composite_primary_keys/attribute_methods.rb +9 -9
  13. data/lib/composite_primary_keys/attribute_methods/dirty.rb +29 -29
  14. data/lib/composite_primary_keys/attribute_methods/read.rb +24 -24
  15. data/lib/composite_primary_keys/attribute_methods/write.rb +30 -30
  16. data/lib/composite_primary_keys/attribute_set/builder.rb +19 -19
  17. data/lib/composite_primary_keys/base.rb +129 -135
  18. data/lib/composite_primary_keys/composite_arrays.rb +43 -43
  19. data/lib/composite_primary_keys/connection_adapters/abstract/connection_specification_changes.rb +2 -3
  20. data/lib/composite_primary_keys/core.rb +60 -60
  21. data/lib/composite_primary_keys/persistence.rb +56 -56
  22. data/lib/composite_primary_keys/relation.rb +68 -68
  23. data/lib/composite_primary_keys/relation/calculations.rb +78 -78
  24. data/lib/composite_primary_keys/relation/finder_methods.rb +179 -179
  25. data/lib/composite_primary_keys/sanitization.rb +52 -52
  26. data/lib/composite_primary_keys/validations/uniqueness.rb +36 -36
  27. data/lib/composite_primary_keys/version.rb +8 -8
  28. data/tasks/databases/sqlserver.rake +27 -27
  29. data/test/abstract_unit.rb +114 -113
  30. data/test/connections/databases.example.yml +25 -25
  31. data/test/connections/native_sqlserver/connection.rb +11 -11
  32. data/test/fixtures/db_definitions/mysql.sql +218 -218
  33. data/test/fixtures/db_definitions/postgresql.sql +220 -220
  34. data/test/fixtures/db_definitions/sqlite.sql +206 -206
  35. data/test/fixtures/db_definitions/sqlserver.drop.sql +91 -91
  36. data/test/fixtures/db_definitions/sqlserver.sql +226 -226
  37. data/test/fixtures/employee.rb +11 -11
  38. data/test/fixtures/salary.rb +5 -5
  39. data/test/test_associations.rb +341 -340
  40. data/test/test_attributes.rb +60 -60
  41. data/test/test_create.rb +157 -157
  42. data/test/test_delete.rb +158 -158
  43. data/test/test_delete_all.rb +33 -28
  44. data/test/test_enum.rb +21 -21
  45. data/test/test_equal.rb +26 -26
  46. data/test/test_find.rb +119 -118
  47. data/test/test_habtm.rb +117 -113
  48. data/test/test_polymorphic.rb +27 -26
  49. data/test/test_tutorial_example.rb +25 -25
  50. metadata +44 -2
@@ -1,25 +1,25 @@
1
- # To run tests:
2
- # 1. Copy this file to test/connections/databases.yml.
3
- # 2. Update to match the databases you want to test against.
4
-
5
- mysql:
6
- adapter: mysql2
7
- username: root
8
- database: composite_primary_keys_unittest
9
-
10
- sqlite3:
11
- adapter: sqlite3
12
- database: db/composite_primary_keys_unittest.sqlite
13
-
14
- postgresql:
15
- adapter: postgresql
16
- database: composite_primary_keys_unittest
17
- username: postgres
18
- host: localhost
19
-
20
- sqlserver:
21
- adapter: sqlserver
22
- database: composite_primary_keys_unittest
23
- username: rails
24
- host: localhost
25
- port: 1433
1
+ # To run tests:
2
+ # 1. Copy this file to test/connections/databases.yml.
3
+ # 2. Update to match the databases you want to test against.
4
+
5
+ mysql:
6
+ adapter: mysql2
7
+ username: root
8
+ database: composite_primary_keys_unittest
9
+
10
+ sqlite3:
11
+ adapter: sqlite3
12
+ database: db/composite_primary_keys_unittest.sqlite
13
+
14
+ postgresql:
15
+ adapter: postgresql
16
+ database: composite_primary_keys_unittest
17
+ username: postgres
18
+ host: localhost
19
+
20
+ sqlserver:
21
+ adapter: sqlserver
22
+ database: composite_primary_keys_unittest
23
+ username: rails
24
+ host: localhost
25
+ port: 1433
@@ -1,11 +1,11 @@
1
- print "Using native SQL Server\n"
2
-
3
- require File.join(PROJECT_ROOT, 'lib', 'composite_primary_keys')
4
-
5
- def connection_string
6
- "-S #{SPEC['host']} -U #{SPEC['username']} -P\"#{SPEC['password']}\""
7
- end
8
-
9
- # Adapter config setup in locals/database_connections.rb
10
- SPEC = CompositePrimaryKeys::ConnectionSpec['sqlserver']
11
- ActiveRecord::Base.establish_connection(SPEC)
1
+ print "Using native SQL Server\n"
2
+
3
+ require File.join(PROJECT_ROOT, 'lib', 'composite_primary_keys')
4
+
5
+ def connection_string
6
+ "-S #{SPEC['host']} -U #{SPEC['username']} -P\"#{SPEC['password']}\""
7
+ end
8
+
9
+ # Adapter config setup in locals/database_connections.rb
10
+ SPEC = CompositePrimaryKeys::ConnectionSpec['sqlserver']
11
+ ActiveRecord::Base.establish_connection(SPEC)
@@ -1,218 +1,218 @@
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 timestamp,
43
- updated_at timestamp,
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
- primary key (id)
120
- );
121
-
122
- create table salaries (
123
- id int not null auto_increment,
124
- employee_id int,
125
- location_id int,
126
- year int not null,
127
- month int not null,
128
- value int default null,
129
- primary key (id)
130
- );
131
-
132
- create table comments (
133
- id int not null auto_increment,
134
- person_id int default null,
135
- shown int default null,
136
- person_type varchar(100) default null,
137
- hack_id int default null,
138
- primary key (id)
139
- );
140
-
141
- create table hacks (
142
- id int not null auto_increment,
143
- name varchar(50) not null,
144
- primary key (id)
145
- );
146
-
147
- create table restaurants (
148
- franchise_id int not null,
149
- store_id int not null,
150
- name varchar(100),
151
- lock_version int default 0,
152
- primary key (franchise_id, store_id)
153
- );
154
-
155
- create table restaurants_suburbs (
156
- franchise_id int not null,
157
- store_id int not null,
158
- city_id int not null,
159
- suburb_id int not null
160
- );
161
-
162
- create table dorms (
163
- id int not null auto_increment,
164
- primary key(id)
165
- );
166
-
167
- create table rooms (
168
- dorm_id int not null,
169
- room_id int not null,
170
- primary key (dorm_id, room_id)
171
- );
172
-
173
- create table room_attributes (
174
- id int not null auto_increment,
175
- name varchar(50),
176
- primary key(id)
177
- );
178
-
179
- create table room_attribute_assignments (
180
- dorm_id int not null,
181
- room_id int not null,
182
- room_attribute_id int not null
183
- );
184
-
185
- create table students (
186
- id int not null auto_increment,
187
- primary key(id)
188
- );
189
-
190
- create table room_assignments (
191
- student_id int not null,
192
- dorm_id int not null,
193
- room_id int not null
194
- );
195
-
196
- create table seats (
197
- flight_number int not null,
198
- seat int not null,
199
- customer int,
200
- primary key (flight_number, seat)
201
- );
202
-
203
- create table capitols (
204
- country varchar(100) default null,
205
- city varchar(100) default null,
206
- primary key (country, city)
207
- );
208
-
209
- create table products_restaurants (
210
- product_id int not null,
211
- franchise_id int not null,
212
- store_id int not null
213
- );
214
-
215
- create table employees_groups (
216
- employee_id int not null,
217
- group_id int not null
218
- );
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 timestamp,
43
+ updated_at timestamp,
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
+ primary key (id)
120
+ );
121
+
122
+ create table salaries (
123
+ id int not null auto_increment,
124
+ employee_id int,
125
+ location_id int,
126
+ year int not null,
127
+ month int not null,
128
+ value int default null,
129
+ primary key (id)
130
+ );
131
+
132
+ create table comments (
133
+ id int not null auto_increment,
134
+ person_id int default null,
135
+ shown int default null,
136
+ person_type varchar(100) default null,
137
+ hack_id int default null,
138
+ primary key (id)
139
+ );
140
+
141
+ create table hacks (
142
+ id int not null auto_increment,
143
+ name varchar(50) not null,
144
+ primary key (id)
145
+ );
146
+
147
+ create table restaurants (
148
+ franchise_id int not null,
149
+ store_id int not null,
150
+ name varchar(100),
151
+ lock_version int default 0,
152
+ primary key (franchise_id, store_id)
153
+ );
154
+
155
+ create table restaurants_suburbs (
156
+ franchise_id int not null,
157
+ store_id int not null,
158
+ city_id int not null,
159
+ suburb_id int not null
160
+ );
161
+
162
+ create table dorms (
163
+ id int not null auto_increment,
164
+ primary key(id)
165
+ );
166
+
167
+ create table rooms (
168
+ dorm_id int not null,
169
+ room_id int not null,
170
+ primary key (dorm_id, room_id)
171
+ );
172
+
173
+ create table room_attributes (
174
+ id int not null auto_increment,
175
+ name varchar(50),
176
+ primary key(id)
177
+ );
178
+
179
+ create table room_attribute_assignments (
180
+ dorm_id int not null,
181
+ room_id int not null,
182
+ room_attribute_id int not null
183
+ );
184
+
185
+ create table students (
186
+ id int not null auto_increment,
187
+ primary key(id)
188
+ );
189
+
190
+ create table room_assignments (
191
+ student_id int not null,
192
+ dorm_id int not null,
193
+ room_id int not null
194
+ );
195
+
196
+ create table seats (
197
+ flight_number int not null,
198
+ seat int not null,
199
+ customer int,
200
+ primary key (flight_number, seat)
201
+ );
202
+
203
+ create table capitols (
204
+ country varchar(100) default null,
205
+ city varchar(100) default null,
206
+ primary key (country, city)
207
+ );
208
+
209
+ create table products_restaurants (
210
+ product_id int not null,
211
+ franchise_id int not null,
212
+ store_id int not null
213
+ );
214
+
215
+ create table employees_groups (
216
+ employee_id int not null,
217
+ group_id int not null
218
+ );