composite_primary_keys 12.0.9 → 12.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/History.rdoc +880 -877
  3. data/README.rdoc +180 -180
  4. data/lib/composite_primary_keys.rb +117 -117
  5. data/lib/composite_primary_keys/active_model/attribute_assignment.rb +19 -19
  6. data/lib/composite_primary_keys/associations/association_scope.rb +68 -68
  7. data/lib/composite_primary_keys/associations/join_dependency.rb +103 -103
  8. data/lib/composite_primary_keys/attribute_methods.rb +9 -9
  9. data/lib/composite_primary_keys/attribute_methods/read.rb +30 -30
  10. data/lib/composite_primary_keys/attribute_methods/write.rb +35 -35
  11. data/lib/composite_primary_keys/base.rb +141 -141
  12. data/lib/composite_primary_keys/connection_adapters/abstract/database_statements.rb +37 -37
  13. data/lib/composite_primary_keys/connection_adapters/sqlserver/database_statements.rb +44 -44
  14. data/lib/composite_primary_keys/core.rb +48 -48
  15. data/lib/composite_primary_keys/persistence.rb +82 -81
  16. data/lib/composite_primary_keys/reflection.rb +29 -29
  17. data/lib/composite_primary_keys/relation.rb +193 -193
  18. data/lib/composite_primary_keys/relation/calculations.rb +81 -81
  19. data/lib/composite_primary_keys/relation/finder_methods.rb +235 -235
  20. data/lib/composite_primary_keys/relation/predicate_builder/association_query_value.rb +20 -20
  21. data/lib/composite_primary_keys/relation/query_methods.rb +42 -42
  22. data/lib/composite_primary_keys/relation/where_clause.rb +23 -23
  23. data/lib/composite_primary_keys/version.rb +8 -8
  24. data/test/abstract_unit.rb +114 -114
  25. data/test/connections/databases.ci.yml +22 -22
  26. data/test/fixtures/db_definitions/db2-create-tables.sql +112 -112
  27. data/test/fixtures/db_definitions/db2-drop-tables.sql +16 -16
  28. data/test/fixtures/db_definitions/mysql.sql +180 -180
  29. data/test/fixtures/db_definitions/oracle.drop.sql +41 -41
  30. data/test/fixtures/db_definitions/oracle.sql +199 -199
  31. data/test/fixtures/db_definitions/postgresql.sql +182 -182
  32. data/test/fixtures/db_definitions/sqlite.sql +169 -169
  33. data/test/fixtures/db_definitions/sqlserver.sql +176 -176
  34. data/test/fixtures/department.rb +16 -16
  35. data/test/fixtures/departments.yml +15 -15
  36. data/test/fixtures/employees.yml +27 -27
  37. data/test/fixtures/restaurants_suburbs.yml +10 -10
  38. data/test/fixtures/streets.yml +16 -16
  39. data/test/fixtures/suburbs.yml +14 -14
  40. data/test/fixtures/user.rb +11 -11
  41. data/test/test_associations.rb +358 -358
  42. data/test/test_attributes.rb +60 -60
  43. data/test/test_calculations.rb +42 -42
  44. data/test/test_create.rb +218 -206
  45. data/test/test_delete.rb +182 -179
  46. data/test/test_exists.rb +39 -39
  47. data/test/test_find.rb +164 -164
  48. data/test/test_ids.rb +112 -112
  49. data/test/test_nested_attributes.rb +67 -67
  50. data/test/test_update.rb +96 -96
  51. metadata +9 -9
@@ -1,112 +1,112 @@
1
- CREATE TABLE reference_types (
2
- reference_type_id integer NOT NULL generated by default as identity (start with 100, increment by 1, no cache),
3
- type_label varchar(50) default NULL,
4
- abbreviation varchar(50) default NULL,
5
- description varchar(50) default NULL,
6
- PRIMARY KEY (reference_type_id)
7
- );
8
-
9
- CREATE TABLE reference_codes (
10
- reference_type_id integer,
11
- reference_code integer NOT NULL,
12
- code_label varchar(50) default NULL,
13
- abbreviation varchar(50) default NULL,
14
- description varchar(50) default NULL,
15
- PRIMARY KEY (reference_type_id,reference_code)
16
- );
17
-
18
- CREATE TABLE products (
19
- id integer NOT NULL,
20
- name varchar(50) default NULL,
21
- PRIMARY KEY (id)
22
- );
23
-
24
- CREATE TABLE tariffs (
25
- tariff_id integer NOT NULL,
26
- start_date date NOT NULL,
27
- amount integer default NULL,
28
- PRIMARY KEY (tariff_id,start_date)
29
- );
30
-
31
- CREATE TABLE product_tariffs (
32
- product_id integer NOT NULL,
33
- tariff_id integer NOT NULL,
34
- tariff_start_date date NOT NULL,
35
- PRIMARY KEY (product_id,tariff_id,tariff_start_date)
36
- );
37
-
38
- CREATE TABLE suburbs (
39
- city_id integer NOT NULL,
40
- suburb_id integer NOT NULL,
41
- name varchar(50) NOT NULL,
42
- PRIMARY KEY (city_id,suburb_id)
43
- );
44
-
45
- CREATE TABLE streets (
46
- id integer NOT NULL ,
47
- city_id integer NOT NULL,
48
- suburb_id integer NOT NULL,
49
- name varchar(50) NOT NULL,
50
- PRIMARY KEY (id)
51
- );
52
-
53
- CREATE TABLE users (
54
- id integer NOT NULL ,
55
- name varchar(50) NOT NULL,
56
- PRIMARY KEY (id)
57
- );
58
-
59
- CREATE TABLE articles (
60
- id integer NOT NULL ,
61
- name varchar(50) NOT NULL,
62
- PRIMARY KEY (id)
63
- );
64
-
65
- CREATE TABLE readings (
66
- id integer NOT NULL ,
67
- user_id integer NOT NULL,
68
- article_id integer NOT NULL,
69
- rating integer NOT NULL,
70
- PRIMARY KEY (id)
71
- );
72
-
73
- CREATE TABLE groups (
74
- id integer NOT NULL ,
75
- name varchar(50) NOT NULL,
76
- PRIMARY KEY (id)
77
- );
78
-
79
- CREATE TABLE memberships (
80
- user_id integer NOT NULL,
81
- group_id integer NOT NULL,
82
- PRIMARY KEY (user_id,group_id)
83
- );
84
-
85
- CREATE TABLE membership_statuses (
86
- id integer NOT NULL ,
87
- user_id integer NOT NULL,
88
- group_id integer NOT NULL,
89
- status varchar(50) NOT NULL,
90
- PRIMARY KEY (id)
91
- );
92
-
93
- create table restaurants (
94
- franchise_id integer not null,
95
- store_id integer not null,
96
- name varchar(100),
97
- lock_version integer default 0,
98
- primary key (franchise_id, store_id)
99
- );
100
-
101
- create table restaurants_suburbs (
102
- franchise_id integer not null,
103
- store_id integer not null,
104
- city_id integer not null,
105
- suburb_id integer not null
106
- );
107
-
108
- create table products_restaurants (
109
- product_id integer not null,
110
- franchise_id integer not null,
111
- store_id integer not null
112
- );
1
+ CREATE TABLE reference_types (
2
+ reference_type_id integer NOT NULL generated by default as identity (start with 100, increment by 1, no cache),
3
+ type_label varchar(50) default NULL,
4
+ abbreviation varchar(50) default NULL,
5
+ description varchar(50) default NULL,
6
+ PRIMARY KEY (reference_type_id)
7
+ );
8
+
9
+ CREATE TABLE reference_codes (
10
+ reference_type_id integer,
11
+ reference_code integer NOT NULL,
12
+ code_label varchar(50) default NULL,
13
+ abbreviation varchar(50) default NULL,
14
+ description varchar(50) default NULL,
15
+ PRIMARY KEY (reference_type_id,reference_code)
16
+ );
17
+
18
+ CREATE TABLE products (
19
+ id integer NOT NULL,
20
+ name varchar(50) default NULL,
21
+ PRIMARY KEY (id)
22
+ );
23
+
24
+ CREATE TABLE tariffs (
25
+ tariff_id integer NOT NULL,
26
+ start_date date NOT NULL,
27
+ amount integer default NULL,
28
+ PRIMARY KEY (tariff_id,start_date)
29
+ );
30
+
31
+ CREATE TABLE product_tariffs (
32
+ product_id integer NOT NULL,
33
+ tariff_id integer NOT NULL,
34
+ tariff_start_date date NOT NULL,
35
+ PRIMARY KEY (product_id,tariff_id,tariff_start_date)
36
+ );
37
+
38
+ CREATE TABLE suburbs (
39
+ city_id integer NOT NULL,
40
+ suburb_id integer NOT NULL,
41
+ name varchar(50) NOT NULL,
42
+ PRIMARY KEY (city_id,suburb_id)
43
+ );
44
+
45
+ CREATE TABLE streets (
46
+ id integer NOT NULL ,
47
+ city_id integer NOT NULL,
48
+ suburb_id integer NOT NULL,
49
+ name varchar(50) NOT NULL,
50
+ PRIMARY KEY (id)
51
+ );
52
+
53
+ CREATE TABLE users (
54
+ id integer NOT NULL ,
55
+ name varchar(50) NOT NULL,
56
+ PRIMARY KEY (id)
57
+ );
58
+
59
+ CREATE TABLE articles (
60
+ id integer NOT NULL ,
61
+ name varchar(50) NOT NULL,
62
+ PRIMARY KEY (id)
63
+ );
64
+
65
+ CREATE TABLE readings (
66
+ id integer NOT NULL ,
67
+ user_id integer NOT NULL,
68
+ article_id integer NOT NULL,
69
+ rating integer NOT NULL,
70
+ PRIMARY KEY (id)
71
+ );
72
+
73
+ CREATE TABLE groups (
74
+ id integer NOT NULL ,
75
+ name varchar(50) NOT NULL,
76
+ PRIMARY KEY (id)
77
+ );
78
+
79
+ CREATE TABLE memberships (
80
+ user_id integer NOT NULL,
81
+ group_id integer NOT NULL,
82
+ PRIMARY KEY (user_id,group_id)
83
+ );
84
+
85
+ CREATE TABLE membership_statuses (
86
+ id integer NOT NULL ,
87
+ user_id integer NOT NULL,
88
+ group_id integer NOT NULL,
89
+ status varchar(50) NOT NULL,
90
+ PRIMARY KEY (id)
91
+ );
92
+
93
+ create table restaurants (
94
+ franchise_id integer not null,
95
+ store_id integer not null,
96
+ name varchar(100),
97
+ lock_version integer default 0,
98
+ primary key (franchise_id, store_id)
99
+ );
100
+
101
+ create table restaurants_suburbs (
102
+ franchise_id integer not null,
103
+ store_id integer not null,
104
+ city_id integer not null,
105
+ suburb_id integer not null
106
+ );
107
+
108
+ create table products_restaurants (
109
+ product_id integer not null,
110
+ franchise_id integer not null,
111
+ store_id integer not null
112
+ );
@@ -1,17 +1,17 @@
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;
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
17
  drop table PRODUCTS_RESTAURANTS;
@@ -1,181 +1,181 @@
1
- create table reference_types (
2
- reference_type_id int not null auto_increment,
3
- type_label varchar(50) default null,
4
- abbreviation varchar(50) default null,
5
- description varchar(50) default null,
6
- primary key (reference_type_id)
7
- );
8
-
9
- create table reference_codes (
10
- reference_type_id int not null,
11
- reference_code int not null,
12
- code_label varchar(50) default null,
13
- abbreviation varchar(50) default null,
14
- description varchar(50) default null,
15
- primary key (reference_type_id, reference_code)
16
- );
17
-
18
- create table products (
19
- id int not null auto_increment,
20
- name varchar(50) default null,
21
- primary key (id)
22
- );
23
-
24
- create table tariffs (
25
- tariff_id int not null,
26
- start_date date not null,
27
- amount integer(11) default null,
28
- created_at datetime,
29
- updated_at datetime,
30
- primary key (tariff_id, start_date)
31
- );
32
-
33
- create table product_tariffs (
34
- product_id int not null,
35
- tariff_id int not null,
36
- tariff_start_date date not null,
37
- primary key (product_id, tariff_id, tariff_start_date)
38
- );
39
-
40
- create table suburbs (
41
- city_id int not null auto_increment,
42
- suburb_id int not null,
43
- name varchar(50) not null,
44
- primary key (city_id, suburb_id)
45
- );
46
-
47
- create table streets (
48
- id int not null auto_increment,
49
- city_id int not null,
50
- suburb_id int not null,
51
- name varchar(50) not null,
52
- primary key (id)
53
- );
54
-
55
- create table users (
56
- id int not null auto_increment,
57
- name varchar(50) not null,
58
- primary key (id)
59
- );
60
-
61
- create table articles (
62
- id int not null auto_increment,
63
- name varchar(50) not null,
64
- primary key (id)
65
- );
66
-
67
- create table readings (
68
- id int not null auto_increment,
69
- user_id int not null,
70
- article_id int not null,
71
- rating int not null,
72
- primary key (id)
73
- );
74
-
75
- create table `groups` (
76
- id int not null auto_increment,
77
- name varchar(50) not null,
78
- primary key (id)
79
- );
80
-
81
- create table memberships (
82
- user_id int not null,
83
- group_id int not null,
84
- primary key (user_id,group_id)
85
- );
86
-
87
- create table membership_statuses (
88
- id int not null auto_increment,
89
- user_id int not null,
90
- group_id int not null,
91
- status varchar(50) not null,
92
- primary key (id)
93
- );
94
-
95
- create table departments (
96
- id int not null auto_increment,
97
- location_id int not null,
98
- primary key (id, location_id)
99
- );
100
-
101
- create table employees (
102
- id int not null auto_increment,
103
- department_id int default null,
104
- location_id int default null,
105
- name varchar(50) default null,
106
- primary key (id)
107
- );
108
-
109
- create table comments (
110
- id int not null auto_increment,
111
- article_id int not null,
112
- person_id int not null,
113
- person_type varchar(100) not null,
114
- primary key (id)
115
- );
116
-
117
- create table restaurants (
118
- franchise_id int not null,
119
- store_id int not null,
120
- name varchar(100),
121
- lock_version int default 0,
122
- primary key (franchise_id, store_id)
123
- );
124
-
125
- create table restaurants_suburbs (
126
- franchise_id int not null,
127
- store_id int not null,
128
- city_id int default null,
129
- suburb_id int default null
130
- );
131
-
132
- create table dorms (
133
- id int not null auto_increment,
134
- primary key(id)
135
- );
136
-
137
- create table rooms (
138
- dorm_id int not null,
139
- room_id int not null,
140
- primary key (dorm_id, room_id)
141
- );
142
-
143
- create table room_attributes (
144
- id int not null auto_increment,
145
- name varchar(50),
146
- primary key(id)
147
- );
148
-
149
- create table room_attribute_assignments (
150
- dorm_id int not null,
151
- room_id int not null,
152
- room_attribute_id int not null
153
- );
154
-
155
- create table students (
156
- id int not null auto_increment,
157
- primary key(id)
158
- );
159
-
160
- create table room_assignments (
161
- student_id int not null,
162
- dorm_id int not null,
163
- room_id int not null
164
- );
165
-
166
- create table capitols (
167
- country varchar(100) not null,
168
- city varchar(100) not null,
169
- primary key (country, city)
170
- );
171
-
172
- create table products_restaurants (
173
- product_id int not null,
174
- franchise_id int default null,
175
- store_id int default null
176
- );
177
-
178
- create table employees_groups (
179
- employee_id int not null,
180
- group_id int not null
1
+ create table reference_types (
2
+ reference_type_id int not null auto_increment,
3
+ type_label varchar(50) default null,
4
+ abbreviation varchar(50) default null,
5
+ description varchar(50) default null,
6
+ primary key (reference_type_id)
7
+ );
8
+
9
+ create table reference_codes (
10
+ reference_type_id int not null,
11
+ reference_code int not null,
12
+ code_label varchar(50) default null,
13
+ abbreviation varchar(50) default null,
14
+ description varchar(50) default null,
15
+ primary key (reference_type_id, reference_code)
16
+ );
17
+
18
+ create table products (
19
+ id int not null auto_increment,
20
+ name varchar(50) default null,
21
+ primary key (id)
22
+ );
23
+
24
+ create table tariffs (
25
+ tariff_id int not null,
26
+ start_date date not null,
27
+ amount integer(11) default null,
28
+ created_at datetime,
29
+ updated_at datetime,
30
+ primary key (tariff_id, start_date)
31
+ );
32
+
33
+ create table product_tariffs (
34
+ product_id int not null,
35
+ tariff_id int not null,
36
+ tariff_start_date date not null,
37
+ primary key (product_id, tariff_id, tariff_start_date)
38
+ );
39
+
40
+ create table suburbs (
41
+ city_id int not null auto_increment,
42
+ suburb_id int not null,
43
+ name varchar(50) not null,
44
+ primary key (city_id, suburb_id)
45
+ );
46
+
47
+ create table streets (
48
+ id int not null auto_increment,
49
+ city_id int not null,
50
+ suburb_id int not null,
51
+ name varchar(50) not null,
52
+ primary key (id)
53
+ );
54
+
55
+ create table users (
56
+ id int not null auto_increment,
57
+ name varchar(50) not null,
58
+ primary key (id)
59
+ );
60
+
61
+ create table articles (
62
+ id int not null auto_increment,
63
+ name varchar(50) not null,
64
+ primary key (id)
65
+ );
66
+
67
+ create table readings (
68
+ id int not null auto_increment,
69
+ user_id int not null,
70
+ article_id int not null,
71
+ rating int not null,
72
+ primary key (id)
73
+ );
74
+
75
+ create table `groups` (
76
+ id int not null auto_increment,
77
+ name varchar(50) not null,
78
+ primary key (id)
79
+ );
80
+
81
+ create table memberships (
82
+ user_id int not null,
83
+ group_id int not null,
84
+ primary key (user_id,group_id)
85
+ );
86
+
87
+ create table membership_statuses (
88
+ id int not null auto_increment,
89
+ user_id int not null,
90
+ group_id int not null,
91
+ status varchar(50) not null,
92
+ primary key (id)
93
+ );
94
+
95
+ create table departments (
96
+ id int not null auto_increment,
97
+ location_id int not null,
98
+ primary key (id, location_id)
99
+ );
100
+
101
+ create table employees (
102
+ id int not null auto_increment,
103
+ department_id int default null,
104
+ location_id int default null,
105
+ name varchar(50) default null,
106
+ primary key (id)
107
+ );
108
+
109
+ create table comments (
110
+ id int not null auto_increment,
111
+ article_id int not null,
112
+ person_id int not null,
113
+ person_type varchar(100) not null,
114
+ primary key (id)
115
+ );
116
+
117
+ create table restaurants (
118
+ franchise_id int not null,
119
+ store_id int not null,
120
+ name varchar(100),
121
+ lock_version int default 0,
122
+ primary key (franchise_id, store_id)
123
+ );
124
+
125
+ create table restaurants_suburbs (
126
+ franchise_id int not null,
127
+ store_id int not null,
128
+ city_id int default null,
129
+ suburb_id int default null
130
+ );
131
+
132
+ create table dorms (
133
+ id int not null auto_increment,
134
+ primary key(id)
135
+ );
136
+
137
+ create table rooms (
138
+ dorm_id int not null,
139
+ room_id int not null,
140
+ primary key (dorm_id, room_id)
141
+ );
142
+
143
+ create table room_attributes (
144
+ id int not null auto_increment,
145
+ name varchar(50),
146
+ primary key(id)
147
+ );
148
+
149
+ create table room_attribute_assignments (
150
+ dorm_id int not null,
151
+ room_id int not null,
152
+ room_attribute_id int not null
153
+ );
154
+
155
+ create table students (
156
+ id int not null auto_increment,
157
+ primary key(id)
158
+ );
159
+
160
+ create table room_assignments (
161
+ student_id int not null,
162
+ dorm_id int not null,
163
+ room_id int not null
164
+ );
165
+
166
+ create table capitols (
167
+ country varchar(100) not null,
168
+ city varchar(100) not null,
169
+ primary key (country, city)
170
+ );
171
+
172
+ create table products_restaurants (
173
+ product_id int not null,
174
+ franchise_id int default null,
175
+ store_id int default null
176
+ );
177
+
178
+ create table employees_groups (
179
+ employee_id int not null,
180
+ group_id int not null
181
181
  );