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