composite_primary_keys 14.0.9 → 14.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.rdoc +10 -0
- data/README.rdoc +182 -182
- data/Rakefile +37 -37
- data/lib/composite_primary_keys/associations/collection_association.rb +38 -38
- data/lib/composite_primary_keys/associations/preloader/association.rb +52 -52
- data/lib/composite_primary_keys/autosave_association.rb +60 -60
- data/lib/composite_primary_keys/composite_arrays.rb +88 -88
- data/lib/composite_primary_keys/composite_predicates.rb +121 -121
- data/lib/composite_primary_keys/connection_adapters/abstract/database_statements.rb +36 -36
- data/lib/composite_primary_keys/core.rb +71 -48
- data/lib/composite_primary_keys/persistence.rb +96 -96
- data/lib/composite_primary_keys/reflection.rb +93 -91
- data/lib/composite_primary_keys/relation/calculations.rb +110 -110
- data/lib/composite_primary_keys/relation/query_methods.rb +40 -40
- data/lib/composite_primary_keys/relation.rb +199 -199
- data/lib/composite_primary_keys/validations/uniqueness.rb +40 -40
- data/lib/composite_primary_keys/version.rb +1 -1
- data/lib/composite_primary_keys.rb +117 -117
- data/scripts/console.rb +48 -48
- data/tasks/databases/trilogy.rake +23 -23
- data/test/abstract_unit.rb +124 -124
- data/test/connections/databases.ci.yml +32 -32
- data/test/fixtures/admin.rb +4 -4
- data/test/fixtures/db_definitions/db2-create-tables.sql +146 -146
- data/test/fixtures/db_definitions/db2-drop-tables.sql +23 -23
- data/test/fixtures/db_definitions/mysql.sql +203 -203
- data/test/fixtures/db_definitions/oracle.drop.sql +45 -45
- data/test/fixtures/db_definitions/oracle.sql +220 -220
- data/test/fixtures/db_definitions/postgresql.sql +205 -205
- data/test/fixtures/db_definitions/sqlite.sql +190 -190
- data/test/fixtures/db_definitions/sqlserver.sql +199 -199
- data/test/fixtures/department.rb +20 -20
- data/test/fixtures/moderator.rb +4 -4
- data/test/fixtures/room.rb +14 -14
- data/test/fixtures/room_assignment.rb +18 -18
- data/test/fixtures/staff_room.rb +6 -6
- data/test/fixtures/staff_room_key.rb +6 -6
- data/test/fixtures/user.rb +14 -14
- data/test/test_associations.rb +403 -403
- data/test/test_composite_arrays.rb +44 -44
- data/test/test_equal.rb +55 -26
- data/test/test_has_one_through.rb +30 -30
- data/test/test_hash.rb +73 -0
- data/test/test_nested_attributes.rb +90 -90
- metadata +7 -8
@@ -1,32 +1,32 @@
|
|
1
|
-
mysql:
|
2
|
-
adapter: mysql2
|
3
|
-
username: github
|
4
|
-
password: github
|
5
|
-
host: 127.0.0.1
|
6
|
-
port: 3306
|
7
|
-
encoding: utf8mb4
|
8
|
-
charset: utf8mb4
|
9
|
-
collation: utf8mb4_bin
|
10
|
-
database: composite_primary_keys_unittest
|
11
|
-
|
12
|
-
postgresql:
|
13
|
-
adapter: postgresql
|
14
|
-
database: composite_primary_keys_unittest
|
15
|
-
username: postgres
|
16
|
-
password: postgres
|
17
|
-
host: localhost
|
18
|
-
|
19
|
-
sqlite:
|
20
|
-
adapter: sqlite3
|
21
|
-
database: <%= File.join(project_root, 'db', 'composite_primary_keys_unittest.sqlite') %>
|
22
|
-
|
23
|
-
trilogy:
|
24
|
-
adapter: trilogy
|
25
|
-
username: github
|
26
|
-
password: github
|
27
|
-
host: 127.0.0.1
|
28
|
-
port: 3306
|
29
|
-
encoding: utf8mb4
|
30
|
-
charset: utf8mb4
|
31
|
-
collation: utf8mb4_bin
|
32
|
-
database: composite_primary_keys_unittest
|
1
|
+
mysql:
|
2
|
+
adapter: mysql2
|
3
|
+
username: github
|
4
|
+
password: github
|
5
|
+
host: 127.0.0.1
|
6
|
+
port: 3306
|
7
|
+
encoding: utf8mb4
|
8
|
+
charset: utf8mb4
|
9
|
+
collation: utf8mb4_bin
|
10
|
+
database: composite_primary_keys_unittest
|
11
|
+
|
12
|
+
postgresql:
|
13
|
+
adapter: postgresql
|
14
|
+
database: composite_primary_keys_unittest
|
15
|
+
username: postgres
|
16
|
+
password: postgres
|
17
|
+
host: localhost
|
18
|
+
|
19
|
+
sqlite:
|
20
|
+
adapter: sqlite3
|
21
|
+
database: <%= File.join(project_root, 'db', 'composite_primary_keys_unittest.sqlite') %>
|
22
|
+
|
23
|
+
trilogy:
|
24
|
+
adapter: trilogy
|
25
|
+
username: github
|
26
|
+
password: github
|
27
|
+
host: 127.0.0.1
|
28
|
+
port: 3306
|
29
|
+
encoding: utf8mb4
|
30
|
+
charset: utf8mb4
|
31
|
+
collation: utf8mb4_bin
|
32
|
+
database: composite_primary_keys_unittest
|
data/test/fixtures/admin.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class Admin < ActiveRecord::Base
|
2
|
-
belongs_to :moderator, :foreign_key => :id, :inverse_of => :admin
|
3
|
-
has_one :user, :through => :moderator
|
4
|
-
end
|
1
|
+
class Admin < ActiveRecord::Base
|
2
|
+
belongs_to :moderator, :foreign_key => :id, :inverse_of => :admin
|
3
|
+
has_one :user, :through => :moderator
|
4
|
+
end
|
@@ -1,146 +1,146 @@
|
|
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 moderators (
|
60
|
-
id integer NOT NULL,
|
61
|
-
PRIMARY KEY (id)
|
62
|
-
);
|
63
|
-
|
64
|
-
CREATE TABLE admins (
|
65
|
-
id integer NOT NULL,
|
66
|
-
PRIMARY KEY (id)
|
67
|
-
);
|
68
|
-
|
69
|
-
CREATE TABLE articles (
|
70
|
-
id integer NOT NULL ,
|
71
|
-
name varchar(50) NOT NULL,
|
72
|
-
PRIMARY KEY (id)
|
73
|
-
);
|
74
|
-
|
75
|
-
CREATE TABLE readings (
|
76
|
-
id integer NOT NULL ,
|
77
|
-
user_id integer NOT NULL,
|
78
|
-
article_id integer NOT NULL,
|
79
|
-
rating integer NOT NULL,
|
80
|
-
PRIMARY KEY (id)
|
81
|
-
);
|
82
|
-
|
83
|
-
CREATE TABLE groups (
|
84
|
-
id integer NOT NULL ,
|
85
|
-
name varchar(50) NOT NULL,
|
86
|
-
PRIMARY KEY (id)
|
87
|
-
);
|
88
|
-
|
89
|
-
CREATE TABLE memberships (
|
90
|
-
user_id integer NOT NULL,
|
91
|
-
group_id integer NOT NULL,
|
92
|
-
PRIMARY KEY (user_id,group_id)
|
93
|
-
);
|
94
|
-
|
95
|
-
CREATE TABLE membership_statuses (
|
96
|
-
id integer NOT NULL ,
|
97
|
-
user_id integer NOT NULL,
|
98
|
-
group_id integer NOT NULL,
|
99
|
-
status varchar(50) NOT NULL,
|
100
|
-
PRIMARY KEY (id)
|
101
|
-
);
|
102
|
-
|
103
|
-
create table restaurants (
|
104
|
-
franchise_id integer not null,
|
105
|
-
store_id integer not null,
|
106
|
-
name varchar(100),
|
107
|
-
lock_version integer default 0,
|
108
|
-
primary key (franchise_id, store_id)
|
109
|
-
);
|
110
|
-
|
111
|
-
create table restaurants_suburbs (
|
112
|
-
franchise_id integer not null,
|
113
|
-
store_id integer not null,
|
114
|
-
city_id integer not null,
|
115
|
-
suburb_id integer not null
|
116
|
-
);
|
117
|
-
|
118
|
-
create table products_restaurants (
|
119
|
-
product_id integer not null,
|
120
|
-
franchise_id integer not null,
|
121
|
-
store_id integer not null
|
122
|
-
);
|
123
|
-
|
124
|
-
create table dorms (
|
125
|
-
id integer not null,
|
126
|
-
primary key (id)
|
127
|
-
)
|
128
|
-
|
129
|
-
create table rooms (
|
130
|
-
dorm_id integer not null,
|
131
|
-
room_id integer not null,
|
132
|
-
primary key (dorm_id, room_id)
|
133
|
-
);
|
134
|
-
|
135
|
-
create table staff_rooms (
|
136
|
-
dorm_id integer not null,
|
137
|
-
room_id integer not null,
|
138
|
-
primary key (dorm_id, room_id)
|
139
|
-
);
|
140
|
-
|
141
|
-
create table staff_room_keys (
|
142
|
-
dorm_id integer not null,
|
143
|
-
room_id integer not null,
|
144
|
-
key_no varchar(50) not null,
|
145
|
-
primary key (dorm_id, room_id)
|
146
|
-
);
|
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 moderators (
|
60
|
+
id integer NOT NULL,
|
61
|
+
PRIMARY KEY (id)
|
62
|
+
);
|
63
|
+
|
64
|
+
CREATE TABLE admins (
|
65
|
+
id integer NOT NULL,
|
66
|
+
PRIMARY KEY (id)
|
67
|
+
);
|
68
|
+
|
69
|
+
CREATE TABLE articles (
|
70
|
+
id integer NOT NULL ,
|
71
|
+
name varchar(50) NOT NULL,
|
72
|
+
PRIMARY KEY (id)
|
73
|
+
);
|
74
|
+
|
75
|
+
CREATE TABLE readings (
|
76
|
+
id integer NOT NULL ,
|
77
|
+
user_id integer NOT NULL,
|
78
|
+
article_id integer NOT NULL,
|
79
|
+
rating integer NOT NULL,
|
80
|
+
PRIMARY KEY (id)
|
81
|
+
);
|
82
|
+
|
83
|
+
CREATE TABLE groups (
|
84
|
+
id integer NOT NULL ,
|
85
|
+
name varchar(50) NOT NULL,
|
86
|
+
PRIMARY KEY (id)
|
87
|
+
);
|
88
|
+
|
89
|
+
CREATE TABLE memberships (
|
90
|
+
user_id integer NOT NULL,
|
91
|
+
group_id integer NOT NULL,
|
92
|
+
PRIMARY KEY (user_id,group_id)
|
93
|
+
);
|
94
|
+
|
95
|
+
CREATE TABLE membership_statuses (
|
96
|
+
id integer NOT NULL ,
|
97
|
+
user_id integer NOT NULL,
|
98
|
+
group_id integer NOT NULL,
|
99
|
+
status varchar(50) NOT NULL,
|
100
|
+
PRIMARY KEY (id)
|
101
|
+
);
|
102
|
+
|
103
|
+
create table restaurants (
|
104
|
+
franchise_id integer not null,
|
105
|
+
store_id integer not null,
|
106
|
+
name varchar(100),
|
107
|
+
lock_version integer default 0,
|
108
|
+
primary key (franchise_id, store_id)
|
109
|
+
);
|
110
|
+
|
111
|
+
create table restaurants_suburbs (
|
112
|
+
franchise_id integer not null,
|
113
|
+
store_id integer not null,
|
114
|
+
city_id integer not null,
|
115
|
+
suburb_id integer not null
|
116
|
+
);
|
117
|
+
|
118
|
+
create table products_restaurants (
|
119
|
+
product_id integer not null,
|
120
|
+
franchise_id integer not null,
|
121
|
+
store_id integer not null
|
122
|
+
);
|
123
|
+
|
124
|
+
create table dorms (
|
125
|
+
id integer not null,
|
126
|
+
primary key (id)
|
127
|
+
)
|
128
|
+
|
129
|
+
create table rooms (
|
130
|
+
dorm_id integer not null,
|
131
|
+
room_id integer not null,
|
132
|
+
primary key (dorm_id, room_id)
|
133
|
+
);
|
134
|
+
|
135
|
+
create table staff_rooms (
|
136
|
+
dorm_id integer not null,
|
137
|
+
room_id integer not null,
|
138
|
+
primary key (dorm_id, room_id)
|
139
|
+
);
|
140
|
+
|
141
|
+
create table staff_room_keys (
|
142
|
+
dorm_id integer not null,
|
143
|
+
room_id integer not null,
|
144
|
+
key_no varchar(50) not null,
|
145
|
+
primary key (dorm_id, room_id)
|
146
|
+
);
|
@@ -1,23 +1,23 @@
|
|
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 MODERATORS;
|
13
|
-
drop table ADMINS;
|
14
|
-
drop table SUBURBS;
|
15
|
-
drop table PRODUCT_TARIFFS;
|
16
|
-
drop table KITCHEN_SINK;
|
17
|
-
drop table RESTAURANTS;
|
18
|
-
drop table RESTAURANTS_SUBURBS;
|
19
|
-
drop table PRODUCTS_RESTAURANTS;
|
20
|
-
drop table DORMS;
|
21
|
-
drop table ROOMS;
|
22
|
-
drop table STAFF_ROOMS;
|
23
|
-
drop table STAFF_ROOM_KEYS;
|
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 MODERATORS;
|
13
|
+
drop table ADMINS;
|
14
|
+
drop table SUBURBS;
|
15
|
+
drop table PRODUCT_TARIFFS;
|
16
|
+
drop table KITCHEN_SINK;
|
17
|
+
drop table RESTAURANTS;
|
18
|
+
drop table RESTAURANTS_SUBURBS;
|
19
|
+
drop table PRODUCTS_RESTAURANTS;
|
20
|
+
drop table DORMS;
|
21
|
+
drop table ROOMS;
|
22
|
+
drop table STAFF_ROOMS;
|
23
|
+
drop table STAFF_ROOM_KEYS;
|