composite_primary_keys 11.0.0.rc1 → 11.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/History.rdoc +763 -754
  3. data/Rakefile +37 -37
  4. data/lib/composite_primary_keys.rb +122 -121
  5. data/lib/composite_primary_keys/arel/sqlserver.rb +37 -37
  6. data/lib/composite_primary_keys/arel/to_sql.rb +32 -32
  7. data/lib/composite_primary_keys/associations/association.rb +23 -23
  8. data/lib/composite_primary_keys/associations/association_scope.rb +68 -68
  9. data/lib/composite_primary_keys/associations/collection_association.rb +31 -31
  10. data/lib/composite_primary_keys/associations/has_many_association.rb +34 -34
  11. data/lib/composite_primary_keys/associations/join_dependency.rb +102 -102
  12. data/lib/composite_primary_keys/associations/preloader/association.rb +117 -117
  13. data/lib/composite_primary_keys/attribute_methods.rb +9 -9
  14. data/lib/composite_primary_keys/attribute_methods/read.rb +27 -27
  15. data/lib/composite_primary_keys/attribute_methods/write.rb +44 -44
  16. data/lib/composite_primary_keys/autosave_association.rb +32 -32
  17. data/lib/composite_primary_keys/base.rb +130 -130
  18. data/lib/composite_primary_keys/composite_arrays.rb +51 -51
  19. data/lib/composite_primary_keys/composite_predicates.rb +69 -69
  20. data/lib/composite_primary_keys/composite_relation.rb +29 -48
  21. data/lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb +29 -22
  22. data/lib/composite_primary_keys/connection_adapters/postgresql/database_statements.rb +26 -26
  23. data/lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb +22 -22
  24. data/lib/composite_primary_keys/core.rb +54 -54
  25. data/lib/composite_primary_keys/counter_cache.rb +28 -0
  26. data/lib/composite_primary_keys/fixtures.rb +26 -26
  27. data/lib/composite_primary_keys/locking/optimistic.rb +56 -56
  28. data/lib/composite_primary_keys/persistence.rb +112 -93
  29. data/lib/composite_primary_keys/reflection.rb +20 -20
  30. data/lib/composite_primary_keys/relation.rb +88 -88
  31. data/lib/composite_primary_keys/relation/calculations.rb +79 -79
  32. data/lib/composite_primary_keys/relation/finder_methods.rb +229 -229
  33. data/lib/composite_primary_keys/relation/predicate_builder/association_query_value.rb +20 -20
  34. data/lib/composite_primary_keys/relation/query_methods.rb +42 -42
  35. data/lib/composite_primary_keys/relation/where_clause.rb +24 -24
  36. data/lib/composite_primary_keys/sanitization.rb +42 -42
  37. data/lib/composite_primary_keys/validations/uniqueness.rb +32 -32
  38. data/lib/composite_primary_keys/version.rb +8 -8
  39. data/scripts/console.rb +0 -0
  40. data/tasks/databases/mysql.rake +40 -40
  41. data/tasks/databases/oracle.rake +41 -41
  42. data/tasks/databases/postgresql.rake +38 -38
  43. data/tasks/databases/sqlite.rake +25 -25
  44. data/tasks/databases/sqlserver.rake +43 -43
  45. data/test/abstract_unit.rb +120 -120
  46. data/test/connections/connection_spec.rb +27 -27
  47. data/test/connections/databases.ci.yml +16 -16
  48. data/test/connections/databases.example.yml +40 -40
  49. data/test/connections/databases.yml +10 -0
  50. data/test/fixtures/article.rb +6 -6
  51. data/test/fixtures/comment.rb +7 -7
  52. data/test/fixtures/db_definitions/db2-create-tables.sql +126 -126
  53. data/test/fixtures/db_definitions/db2-drop-tables.sql +18 -18
  54. data/test/fixtures/db_definitions/mysql.sql +226 -226
  55. data/test/fixtures/db_definitions/oracle.drop.sql +49 -49
  56. data/test/fixtures/db_definitions/oracle.sql +246 -246
  57. data/test/fixtures/db_definitions/postgresql.sql +229 -229
  58. data/test/fixtures/db_definitions/sqlite.sql +214 -214
  59. data/test/fixtures/db_definitions/sqlserver.sql +211 -211
  60. data/test/fixtures/dorm.rb +2 -2
  61. data/test/fixtures/employee.rb +10 -10
  62. data/test/fixtures/employees.yml +18 -18
  63. data/test/fixtures/membership.rb +6 -6
  64. data/test/fixtures/membership_statuses.yml +16 -16
  65. data/test/fixtures/memberships.yml +10 -10
  66. data/test/fixtures/pk_called_id.rb +5 -5
  67. data/test/fixtures/pk_called_ids.yml +11 -11
  68. data/test/fixtures/product_tariffs.yml +14 -14
  69. data/test/fixtures/reference_code.rb +7 -7
  70. data/test/fixtures/reference_type.rb +12 -12
  71. data/test/fixtures/restaurants_suburb.rb +2 -2
  72. data/test/fixtures/salary.rb +5 -5
  73. data/test/fixtures/suburb.rb +5 -5
  74. data/test/fixtures/tariff.rb +5 -5
  75. data/test/fixtures/tariffs.yml +14 -14
  76. data/test/fixtures/topic.rb +5 -5
  77. data/test/fixtures/topic_source.rb +6 -6
  78. data/test/fixtures/topic_sources.yml +3 -3
  79. data/test/fixtures/topics.yml +8 -8
  80. data/test/fixtures/user.rb +10 -10
  81. data/test/fixtures/users.yml +10 -10
  82. data/test/test_associations.rb +345 -345
  83. data/test/test_attribute_methods.rb +63 -63
  84. data/test/test_attributes.rb +60 -60
  85. data/test/test_calculations.rb +42 -42
  86. data/test/test_callbacks.rb +99 -99
  87. data/test/test_counter_cache.rb +1 -1
  88. data/test/test_create.rb +164 -164
  89. data/test/test_delete.rb +167 -167
  90. data/test/test_dumpable.rb +15 -15
  91. data/test/test_enum.rb +21 -21
  92. data/test/test_equal.rb +26 -26
  93. data/test/test_find.rb +137 -137
  94. data/test/test_habtm.rb +141 -141
  95. data/test/test_ids.rb +113 -113
  96. data/test/test_nested_attributes.rb +124 -124
  97. data/test/test_optimistic.rb +18 -18
  98. data/test/test_polymorphic.rb +27 -27
  99. data/test/test_predicates.rb +59 -59
  100. data/test/test_preload.rb +94 -94
  101. data/test/test_santiago.rb +23 -23
  102. data/test/test_suite.rb +34 -34
  103. data/test/test_touch.rb +23 -23
  104. data/test/test_tutorial_example.rb +25 -25
  105. data/test/test_update.rb +76 -76
  106. metadata +29 -28
@@ -1,19 +1,19 @@
1
- drop table MEMBERSHIPS;
2
- drop table REFERENCE_CODES;
3
- drop table TARIFFS;
4
- drop table ARTICLES;
5
- drop table GROUPS;
6
- drop table MEMBERSHIP_STATUSES;
7
- drop table READINGS;
8
- drop table REFERENCE_TYPES;
9
- drop table STREETS;
10
- drop table PRODUCTS;
11
- drop table USERS;
12
- drop table SUBURBS;
13
- drop table PRODUCT_TARIFFS;
14
- drop table KITCHEN_SINK;
15
- drop table RESTAURANTS;
16
- drop table RESTAURANTS_SUBURBS;
17
- drop table PRODUCTS_RESTAURANTS;
18
- drop table TOPICS;
1
+ drop table MEMBERSHIPS;
2
+ drop table REFERENCE_CODES;
3
+ drop table TARIFFS;
4
+ drop table ARTICLES;
5
+ drop table GROUPS;
6
+ drop table MEMBERSHIP_STATUSES;
7
+ drop table READINGS;
8
+ drop table REFERENCE_TYPES;
9
+ drop table STREETS;
10
+ drop table PRODUCTS;
11
+ drop table USERS;
12
+ drop table SUBURBS;
13
+ drop table PRODUCT_TARIFFS;
14
+ drop table KITCHEN_SINK;
15
+ drop table RESTAURANTS;
16
+ drop table RESTAURANTS_SUBURBS;
17
+ drop table PRODUCTS_RESTAURANTS;
18
+ drop table TOPICS;
19
19
  drop table TOPIC_SOURCES;
@@ -1,227 +1,227 @@
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 datetime,
43
- updated_at datetime,
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 default null,
159
- suburb_id int default 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) not null,
205
- city varchar(100) not null,
206
- primary key (country, city)
207
- );
208
-
209
- create table products_restaurants (
210
- product_id int not null,
211
- franchise_id int default null,
212
- store_id int default null
213
- );
214
-
215
- create table employees_groups (
216
- employee_id int not null,
217
- group_id int not null
218
- );
219
-
220
- create table pk_called_ids (
221
- id integer not null,
222
- reference_code int not null,
223
- code_label varchar(50) default null,
224
- abbreviation varchar(50) default null,
225
- description varchar(50) default null,
226
- primary key (id, reference_code)
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 datetime,
43
+ updated_at datetime,
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 default null,
159
+ suburb_id int default 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) not null,
205
+ city varchar(100) not null,
206
+ primary key (country, city)
207
+ );
208
+
209
+ create table products_restaurants (
210
+ product_id int not null,
211
+ franchise_id int default null,
212
+ store_id int default null
213
+ );
214
+
215
+ create table employees_groups (
216
+ employee_id int not null,
217
+ group_id int not null
218
+ );
219
+
220
+ create table pk_called_ids (
221
+ id integer not null,
222
+ reference_code int not null,
223
+ code_label varchar(50) default null,
224
+ abbreviation varchar(50) default null,
225
+ description varchar(50) default null,
226
+ primary key (id, reference_code)
227
227
  );