composite_primary_keys 7.0.13 → 7.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/History.rdoc +615 -608
  3. data/lib/composite_primary_keys.rb +110 -110
  4. data/lib/composite_primary_keys/associations/association.rb +23 -23
  5. data/lib/composite_primary_keys/associations/association_scope.rb +77 -77
  6. data/lib/composite_primary_keys/associations/has_and_belongs_to_many_association.rb +59 -59
  7. data/lib/composite_primary_keys/associations/has_many_association.rb +56 -56
  8. data/lib/composite_primary_keys/associations/join_dependency.rb +89 -89
  9. data/lib/composite_primary_keys/associations/join_dependency/join_part.rb +38 -38
  10. data/lib/composite_primary_keys/associations/preloader/association.rb +78 -78
  11. data/lib/composite_primary_keys/associations/preloader/has_and_belongs_to_many.rb +46 -46
  12. data/lib/composite_primary_keys/attribute_methods/dirty.rb +26 -26
  13. data/lib/composite_primary_keys/attribute_methods/read.rb +34 -34
  14. data/lib/composite_primary_keys/attribute_methods/write.rb +36 -36
  15. data/lib/composite_primary_keys/base.rb +0 -6
  16. data/lib/composite_primary_keys/composite_arrays.rb +30 -30
  17. data/lib/composite_primary_keys/connection_adapters/abstract/connection_specification_changes.rb +4 -2
  18. data/lib/composite_primary_keys/connection_adapters/sqlserver_adapter.rb +17 -0
  19. data/lib/composite_primary_keys/core.rb +47 -47
  20. data/lib/composite_primary_keys/persistence.rb +60 -60
  21. data/lib/composite_primary_keys/relation.rb +56 -56
  22. data/lib/composite_primary_keys/relation/calculations.rb +75 -65
  23. data/lib/composite_primary_keys/relation/finder_methods.rb +196 -196
  24. data/lib/composite_primary_keys/sanitization.rb +52 -52
  25. data/lib/composite_primary_keys/validations/uniqueness.rb +37 -39
  26. data/lib/composite_primary_keys/version.rb +8 -8
  27. data/tasks/databases/sqlserver.rake +40 -27
  28. data/test/connections/databases.example.yml +18 -18
  29. data/test/connections/native_sqlserver/connection.rb +14 -11
  30. data/test/fixtures/db_definitions/mysql.sql +208 -208
  31. data/test/fixtures/db_definitions/postgresql.sql +210 -210
  32. data/test/fixtures/db_definitions/sqlite.sql +197 -197
  33. data/test/fixtures/db_definitions/sqlserver.drop.sql +94 -91
  34. data/test/fixtures/db_definitions/sqlserver.sql +232 -226
  35. data/test/fixtures/employee.rb +5 -5
  36. data/test/test_associations.rb +275 -275
  37. data/test/test_attributes.rb +60 -60
  38. data/test/test_create.rb +112 -112
  39. data/test/test_delete.rb +152 -148
  40. data/test/test_delete_all.rb +21 -21
  41. data/test/test_enum.rb +20 -20
  42. data/test/test_equal.rb +1 -1
  43. data/test/test_tutorial_example.rb +21 -21
  44. metadata +3 -2
@@ -1,92 +1,95 @@
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
+ go
93
+
94
+ DROP TABLE employees_groups;
92
95
  go
@@ -1,226 +1,232 @@
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
227
+
228
+ CREATE TABLE employees_groups (
229
+ employee_id [int] NOT NULL,
230
+ group_id [int] NOT NULL
231
+ );
232
+ go