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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/History.rdoc +10 -0
  3. data/README.rdoc +182 -182
  4. data/Rakefile +37 -37
  5. data/lib/composite_primary_keys/associations/collection_association.rb +38 -38
  6. data/lib/composite_primary_keys/associations/preloader/association.rb +52 -52
  7. data/lib/composite_primary_keys/autosave_association.rb +60 -60
  8. data/lib/composite_primary_keys/composite_arrays.rb +88 -88
  9. data/lib/composite_primary_keys/composite_predicates.rb +121 -121
  10. data/lib/composite_primary_keys/connection_adapters/abstract/database_statements.rb +36 -36
  11. data/lib/composite_primary_keys/core.rb +71 -48
  12. data/lib/composite_primary_keys/persistence.rb +96 -96
  13. data/lib/composite_primary_keys/reflection.rb +93 -91
  14. data/lib/composite_primary_keys/relation/calculations.rb +110 -110
  15. data/lib/composite_primary_keys/relation/query_methods.rb +40 -40
  16. data/lib/composite_primary_keys/relation.rb +199 -199
  17. data/lib/composite_primary_keys/validations/uniqueness.rb +40 -40
  18. data/lib/composite_primary_keys/version.rb +1 -1
  19. data/lib/composite_primary_keys.rb +117 -117
  20. data/scripts/console.rb +48 -48
  21. data/tasks/databases/trilogy.rake +23 -23
  22. data/test/abstract_unit.rb +124 -124
  23. data/test/connections/databases.ci.yml +32 -32
  24. data/test/fixtures/admin.rb +4 -4
  25. data/test/fixtures/db_definitions/db2-create-tables.sql +146 -146
  26. data/test/fixtures/db_definitions/db2-drop-tables.sql +23 -23
  27. data/test/fixtures/db_definitions/mysql.sql +203 -203
  28. data/test/fixtures/db_definitions/oracle.drop.sql +45 -45
  29. data/test/fixtures/db_definitions/oracle.sql +220 -220
  30. data/test/fixtures/db_definitions/postgresql.sql +205 -205
  31. data/test/fixtures/db_definitions/sqlite.sql +190 -190
  32. data/test/fixtures/db_definitions/sqlserver.sql +199 -199
  33. data/test/fixtures/department.rb +20 -20
  34. data/test/fixtures/moderator.rb +4 -4
  35. data/test/fixtures/room.rb +14 -14
  36. data/test/fixtures/room_assignment.rb +18 -18
  37. data/test/fixtures/staff_room.rb +6 -6
  38. data/test/fixtures/staff_room_key.rb +6 -6
  39. data/test/fixtures/user.rb +14 -14
  40. data/test/test_associations.rb +403 -403
  41. data/test/test_composite_arrays.rb +44 -44
  42. data/test/test_equal.rb +55 -26
  43. data/test/test_has_one_through.rb +30 -30
  44. data/test/test_hash.rb +73 -0
  45. data/test/test_nested_attributes.rb +90 -90
  46. 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
@@ -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;