composite_primary_keys 7.0.16 → 8.0.0

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 (95) hide show
  1. checksums.yaml +4 -4
  2. data/History.rdoc +600 -623
  3. data/lib/composite_primary_keys.rb +113 -115
  4. data/lib/composite_primary_keys/associations/association.rb +23 -23
  5. data/lib/composite_primary_keys/associations/association_scope.rb +73 -77
  6. data/lib/composite_primary_keys/associations/collection_association.rb +15 -0
  7. data/lib/composite_primary_keys/associations/has_many_association.rb +69 -56
  8. data/lib/composite_primary_keys/associations/has_many_through_association.rb +30 -28
  9. data/lib/composite_primary_keys/associations/join_dependency.rb +87 -89
  10. data/lib/composite_primary_keys/associations/join_dependency/join_association.rb +22 -22
  11. data/lib/composite_primary_keys/associations/preloader/association.rb +90 -78
  12. data/lib/composite_primary_keys/associations/preloader/belongs_to.rb +19 -19
  13. data/lib/composite_primary_keys/associations/singular_association.rb +15 -0
  14. data/lib/composite_primary_keys/attribute_methods.rb +9 -0
  15. data/lib/composite_primary_keys/attribute_methods/dirty.rb +29 -26
  16. data/lib/composite_primary_keys/attribute_methods/read.rb +19 -34
  17. data/lib/composite_primary_keys/attribute_methods/write.rb +30 -36
  18. data/lib/composite_primary_keys/attribute_set/builder.rb +20 -0
  19. data/lib/composite_primary_keys/base.rb +135 -129
  20. data/lib/composite_primary_keys/composite_arrays.rb +30 -30
  21. data/lib/composite_primary_keys/composite_predicates.rb +50 -50
  22. data/lib/composite_primary_keys/composite_relation.rb +48 -48
  23. data/lib/composite_primary_keys/connection_adapters/abstract/connection_specification_changes.rb +2 -4
  24. data/lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb +46 -60
  25. data/lib/composite_primary_keys/core.rb +69 -47
  26. data/lib/composite_primary_keys/fixtures.rb +22 -22
  27. data/lib/composite_primary_keys/persistence.rb +56 -60
  28. data/lib/composite_primary_keys/relation.rb +68 -56
  29. data/lib/composite_primary_keys/relation/calculations.rb +79 -75
  30. data/lib/composite_primary_keys/relation/finder_methods.rb +175 -196
  31. data/lib/composite_primary_keys/relation/query_methods.rb +40 -40
  32. data/lib/composite_primary_keys/sanitization.rb +52 -52
  33. data/lib/composite_primary_keys/validations/uniqueness.rb +36 -37
  34. data/lib/composite_primary_keys/version.rb +8 -8
  35. data/tasks/databases/oracle.rake +25 -25
  36. data/tasks/databases/sqlserver.rake +27 -40
  37. data/test/abstract_unit.rb +113 -113
  38. data/test/connections/databases.ci.yml +15 -15
  39. data/test/connections/databases.example.yml +18 -18
  40. data/test/connections/native_oracle/connection.rb +11 -11
  41. data/test/connections/native_oracle_enhanced/connection.rb +16 -16
  42. data/test/connections/native_sqlserver/connection.rb +11 -14
  43. data/test/fixtures/comment.rb +7 -7
  44. data/test/fixtures/db_definitions/db2-create-tables.sql +125 -126
  45. data/test/fixtures/db_definitions/db2-drop-tables.sql +18 -18
  46. data/test/fixtures/db_definitions/mysql.sql +207 -208
  47. data/test/fixtures/db_definitions/oracle.drop.sql +45 -45
  48. data/test/fixtures/db_definitions/oracle.sql +222 -223
  49. data/test/fixtures/db_definitions/postgresql.sql +209 -210
  50. data/test/fixtures/db_definitions/sqlite.sql +196 -197
  51. data/test/fixtures/db_definitions/sqlserver.drop.sql +91 -94
  52. data/test/fixtures/db_definitions/sqlserver.sql +225 -232
  53. data/test/fixtures/dorm.rb +2 -2
  54. data/test/fixtures/employee.rb +5 -5
  55. data/test/fixtures/membership.rb +6 -6
  56. data/test/fixtures/membership_statuses.yml +16 -16
  57. data/test/fixtures/memberships.yml +10 -10
  58. data/test/fixtures/product_tariffs.yml +14 -14
  59. data/test/fixtures/reference_code.rb +7 -7
  60. data/test/fixtures/restaurants_suburb.rb +2 -2
  61. data/test/fixtures/suburb.rb +5 -5
  62. data/test/fixtures/topic.rb +5 -5
  63. data/test/fixtures/topic_source.rb +6 -6
  64. data/test/fixtures/topic_sources.yml +3 -3
  65. data/test/fixtures/topics.yml +8 -8
  66. data/test/fixtures/users.yml +10 -10
  67. data/test/test_associations.rb +295 -275
  68. data/test/test_attribute_methods.rb +63 -63
  69. data/test/test_attributes.rb +60 -60
  70. data/test/test_calculations.rb +37 -42
  71. data/test/test_callbacks.rb +99 -99
  72. data/test/test_create.rb +112 -112
  73. data/test/test_delete.rb +148 -152
  74. data/test/test_delete_all.rb +28 -26
  75. data/test/test_dumpable.rb +15 -15
  76. data/test/test_enum.rb +21 -20
  77. data/test/test_equal.rb +26 -26
  78. data/test/test_find.rb +118 -118
  79. data/test/test_habtm.rb +113 -113
  80. data/test/test_nested_attributes.rb +124 -124
  81. data/test/test_polymorphic.rb +26 -26
  82. data/test/test_predicates.rb +40 -40
  83. data/test/test_santiago.rb +23 -23
  84. data/test/test_suite.rb +33 -34
  85. data/test/test_touch.rb +23 -23
  86. data/test/test_tutorial_example.rb +21 -21
  87. data/test/test_update.rb +71 -71
  88. metadata +9 -13
  89. data/lib/composite_primary_keys/arel/visitors/to_sql.rb +0 -20
  90. data/lib/composite_primary_keys/associations/has_and_belongs_to_many_association.rb +0 -59
  91. data/lib/composite_primary_keys/associations/join_dependency/join_part.rb +0 -39
  92. data/lib/composite_primary_keys/associations/preloader/has_and_belongs_to_many.rb +0 -46
  93. data/lib/composite_primary_keys/connection_adapters/sqlserver_adapter.rb +0 -17
  94. data/lib/composite_primary_keys/locking/optimistic.rb +0 -55
  95. data/test/test_optimistic.rb +0 -18
@@ -1,197 +1,196 @@
1
- create table topics (
2
- id int 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 integer primary key,
17
- type_label varchar(50) default null,
18
- abbreviation varchar(50) default null,
19
- description varchar(50) default null
20
- );
21
-
22
- create table reference_codes (
23
- reference_type_id int(11),
24
- reference_code int(11) not null,
25
- code_label varchar(50) default null,
26
- abbreviation varchar(50) default null,
27
- description varchar(50) default null,
28
- primary key (reference_type_id, reference_code)
29
- );
30
-
31
- create table products (
32
- id int(11) not null primary key,
33
- name varchar(50) default null,
34
- created_at TIMESTAMP,
35
- updated_at TIMESTAMP
36
- );
37
-
38
- create table tariffs (
39
- tariff_id int(11) 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(11) not null,
49
- tariff_id int(11) 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(11) not null,
56
- suburb_id int(11) not null,
57
- name varchar(50) not null,
58
- primary key (city_id, suburb_id)
59
- );
60
-
61
- create table streets (
62
- id integer not null primary key autoincrement,
63
- city_id int(11) not null,
64
- suburb_id int(11) not null,
65
- name varchar(50) not null
66
- );
67
-
68
- create table users (
69
- id integer not null primary key autoincrement,
70
- name varchar(50) not null
71
- );
72
-
73
- create table articles (
74
- id integer not null primary key autoincrement,
75
- name varchar(50) not null
76
- );
77
-
78
- create table readings (
79
- id integer not null primary key autoincrement,
80
- user_id int(11) not null,
81
- article_id int(11) not null,
82
- rating int(11) not null
83
- );
84
-
85
- create table groups (
86
- id integer not null primary key autoincrement,
87
- name varchar(50) not null
88
- );
89
-
90
- create table memberships (
91
- user_id int not null,
92
- group_id int not null,
93
- primary key (user_id, group_id)
94
- );
95
-
96
- create table membership_statuses (
97
- id integer not null primary key autoincrement,
98
- user_id int not null,
99
- group_id int not null,
100
- status varchar(50) not null
101
- );
102
-
103
- create table departments (
104
- department_id integer not null,
105
- location_id integer not null,
106
- primary key (department_id, location_id)
107
- );
108
-
109
- create table employees (
110
- id integer not null primary key autoincrement,
111
- department_id integer null,
112
- location_id integer null
113
- );
114
-
115
- create table comments (
116
- id integer not null primary key autoincrement,
117
- person_id int null,
118
- shown int null,
119
- person_type varchar(100) null,
120
- hack_id int null
121
- );
122
-
123
- create table hacks (
124
- id integer not null primary key autoincrement,
125
- name varchar(50) not null
126
- );
127
-
128
- create table restaurants (
129
- franchise_id integer not null,
130
- store_id integer not null,
131
- name varchar(100),
132
- lock_version integer default 0,
133
- primary key (franchise_id, store_id)
134
- );
135
-
136
- create table restaurants_suburbs (
137
- franchise_id integer not null,
138
- store_id integer not null,
139
- city_id integer not null,
140
- suburb_id integer not null
141
- );
142
-
143
- create table dorms (
144
- id integer not null primary key autoincrement
145
- );
146
-
147
- create table rooms (
148
- dorm_id integer not null,
149
- room_id integer not null,
150
- primary key (dorm_id, room_id)
151
- );
152
-
153
- create table room_attributes (
154
- id integer not null primary key autoincrement,
155
- name varchar(50)
156
- );
157
-
158
- create table room_attribute_assignments (
159
- dorm_id integer not null,
160
- room_id integer not null,
161
- room_attribute_id integer not null
162
- );
163
-
164
- create table students (
165
- id integer not null primary key autoincrement
166
- );
167
-
168
- create table room_assignments (
169
- student_id integer not null,
170
- dorm_id integer not null,
171
- room_id integer not null
172
- );
173
-
174
- create table seats (
175
- flight_number integer not_null,
176
- seat integer not_null,
177
- customer integer,
178
- primary key (flight_number, seat)
179
- );
180
-
181
- create table capitols (
182
- country text not null,
183
- city text not null,
184
- primary key (country, city)
185
- );
186
-
187
- create table products_restaurants (
188
- product_id integer not null,
189
- franchise_id integer not null,
190
- store_id integer not null
191
- );
192
-
193
- create table employees_groups (
194
- employee_id integer not null,
195
- group_id integer not null
196
- );
197
-
1
+ create table topics (
2
+ id int 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 integer primary key,
17
+ type_label varchar(50) default null,
18
+ abbreviation varchar(50) default null,
19
+ description varchar(50) default null
20
+ );
21
+
22
+ create table reference_codes (
23
+ reference_type_id int(11),
24
+ reference_code int(11) not null,
25
+ code_label varchar(50) default null,
26
+ abbreviation varchar(50) default null,
27
+ description varchar(50) default null,
28
+ primary key (reference_type_id, reference_code)
29
+ );
30
+
31
+ create table products (
32
+ id int(11) not null primary key,
33
+ name varchar(50) default null,
34
+ created_at TIMESTAMP,
35
+ updated_at TIMESTAMP
36
+ );
37
+
38
+ create table tariffs (
39
+ tariff_id int(11) 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(11) not null,
49
+ tariff_id int(11) 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(11) not null,
56
+ suburb_id int(11) not null,
57
+ name varchar(50) not null,
58
+ primary key (city_id, suburb_id)
59
+ );
60
+
61
+ create table streets (
62
+ id integer not null primary key autoincrement,
63
+ city_id int(11) not null,
64
+ suburb_id int(11) not null,
65
+ name varchar(50) not null
66
+ );
67
+
68
+ create table users (
69
+ id integer not null primary key autoincrement,
70
+ name varchar(50) not null
71
+ );
72
+
73
+ create table articles (
74
+ id integer not null primary key autoincrement,
75
+ name varchar(50) not null
76
+ );
77
+
78
+ create table readings (
79
+ id integer not null primary key autoincrement,
80
+ user_id int(11) not null,
81
+ article_id int(11) not null,
82
+ rating int(11) not null
83
+ );
84
+
85
+ create table groups (
86
+ id integer not null primary key autoincrement,
87
+ name varchar(50) not null
88
+ );
89
+
90
+ create table memberships (
91
+ user_id int not null,
92
+ group_id int not null,
93
+ primary key (user_id, group_id)
94
+ );
95
+
96
+ create table membership_statuses (
97
+ id integer not null primary key autoincrement,
98
+ user_id int not null,
99
+ group_id int not null,
100
+ status varchar(50) not null
101
+ );
102
+
103
+ create table departments (
104
+ department_id integer not null,
105
+ location_id integer not null,
106
+ primary key (department_id, location_id)
107
+ );
108
+
109
+ create table employees (
110
+ id integer not null primary key autoincrement,
111
+ department_id integer null,
112
+ location_id integer null
113
+ );
114
+
115
+ create table comments (
116
+ id integer not null primary key autoincrement,
117
+ person_id int null,
118
+ shown int null,
119
+ person_type varchar(100) null,
120
+ hack_id int null
121
+ );
122
+
123
+ create table hacks (
124
+ id integer not null primary key autoincrement,
125
+ name varchar(50) not null
126
+ );
127
+
128
+ create table restaurants (
129
+ franchise_id integer not null,
130
+ store_id integer not null,
131
+ name varchar(100),
132
+ primary key (franchise_id, store_id)
133
+ );
134
+
135
+ create table restaurants_suburbs (
136
+ franchise_id integer not null,
137
+ store_id integer not null,
138
+ city_id integer not null,
139
+ suburb_id integer not null
140
+ );
141
+
142
+ create table dorms (
143
+ id integer not null primary key autoincrement
144
+ );
145
+
146
+ create table rooms (
147
+ dorm_id integer not null,
148
+ room_id integer not null,
149
+ primary key (dorm_id, room_id)
150
+ );
151
+
152
+ create table room_attributes (
153
+ id integer not null primary key autoincrement,
154
+ name varchar(50)
155
+ );
156
+
157
+ create table room_attribute_assignments (
158
+ dorm_id integer not null,
159
+ room_id integer not null,
160
+ room_attribute_id integer not null
161
+ );
162
+
163
+ create table students (
164
+ id integer not null primary key autoincrement
165
+ );
166
+
167
+ create table room_assignments (
168
+ student_id integer not null,
169
+ dorm_id integer not null,
170
+ room_id integer not null
171
+ );
172
+
173
+ create table seats (
174
+ flight_number integer not_null,
175
+ seat integer not_null,
176
+ customer integer,
177
+ primary key (flight_number, seat)
178
+ );
179
+
180
+ create table capitols (
181
+ country text not null,
182
+ city text not null,
183
+ primary key (country, city)
184
+ );
185
+
186
+ create table products_restaurants (
187
+ product_id integer not null,
188
+ franchise_id integer not null,
189
+ store_id integer not null
190
+ );
191
+
192
+ create table employees_groups (
193
+ employee_id integer not null,
194
+ group_id integer not null
195
+ );
196
+
@@ -1,95 +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;
92
- go
93
-
94
- DROP TABLE employees_groups;
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;
95
92
  go