composite_primary_keys 0.8.2 → 0.8.3
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.
- data/History.txt +7 -0
- data/Manifest.txt +2 -0
- data/Rakefile +3 -3
- data/lib/composite_primary_keys/base.rb +1 -1
- data/lib/composite_primary_keys/version.rb +1 -1
- data/test/fixtures/db_definitions/oracle.drop.sql +21 -0
- data/test/fixtures/db_definitions/oracle.sql +111 -0
- data/website/index.html +36 -5
- data/website/index.txt +29 -2
- data/website/version-raw.js +1 -1
- data/website/version.js +1 -1
- metadata +4 -2
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
@@ -25,6 +25,8 @@ test/connections/native_sqlite/connection.rb
|
|
25
25
|
test/fixtures/article.rb
|
26
26
|
test/fixtures/articles.yml
|
27
27
|
test/fixtures/db_definitions/mysql.sql
|
28
|
+
test/fixtures/db_definitions/oracle.drop.sql
|
29
|
+
test/fixtures/db_definitions/oracle.sql
|
28
30
|
test/fixtures/db_definitions/postgresql.sql
|
29
31
|
test/fixtures/db_definitions/sqlite.sql
|
30
32
|
test/fixtures/group.rb
|
data/Rakefile
CHANGED
@@ -19,8 +19,8 @@ RUBYFORGE_PROJECT = "compositekeys"
|
|
19
19
|
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
20
20
|
|
21
21
|
REV = nil #File.read(".svn/entries")[/committed-rev="(\d+)"/, 1] rescue nil
|
22
|
-
|
23
|
-
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
22
|
+
VER = ENV['VERSION'] || (CompositePrimaryKeys::VERSION::STRING + (REV ? ".#{REV}" : ""))
|
23
|
+
CLEAN.include ['**/.*.sw?', '*.gem', '.config','debug.log','*.db','logfile','.DS_Store']
|
24
24
|
RDOC_OPTS = ['--quiet', '--title', "newgem documentation",
|
25
25
|
"--opname", "index.html",
|
26
26
|
"--line-numbers",
|
@@ -35,7 +35,7 @@ end
|
|
35
35
|
|
36
36
|
# Generate all the Rake tasks
|
37
37
|
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
38
|
-
hoe = Hoe.new(GEM_NAME,
|
38
|
+
hoe = Hoe.new(GEM_NAME, VER) do |p|
|
39
39
|
p.author = AUTHOR
|
40
40
|
p.description = DESCRIPTION
|
41
41
|
p.email = EMAIL
|
@@ -303,7 +303,7 @@ module CompositePrimaryKeys
|
|
303
303
|
if result.size == ids.size
|
304
304
|
ids.size == 1 ? result[0] : result
|
305
305
|
else
|
306
|
-
raise RecordNotFound, "Couldn't find all #{name.pluralize} with IDs (#{ids_list})#{conditions}"
|
306
|
+
raise ::ActiveRecord::RecordNotFound, "Couldn't find all #{name.pluralize} with IDs (#{ids_list})#{conditions}"
|
307
307
|
end
|
308
308
|
end
|
309
309
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
drop table reference_types;
|
2
|
+
drop sequence reference_types_seq;
|
3
|
+
drop table reference_codes;
|
4
|
+
drop table products;
|
5
|
+
drop sequence products_seq;
|
6
|
+
drop table tariffs;
|
7
|
+
drop table product_tariffs;
|
8
|
+
drop table suburbs;
|
9
|
+
drop table streets;
|
10
|
+
drop sequence streets_seq;
|
11
|
+
drop table users;
|
12
|
+
drop sequence users_seq;
|
13
|
+
drop table articles;
|
14
|
+
drop sequence articles_seq;
|
15
|
+
drop table readings;
|
16
|
+
drop sequence readings_seq;
|
17
|
+
drop table groups;
|
18
|
+
drop sequence groups_seq;
|
19
|
+
drop table memberships;
|
20
|
+
drop table membership_statuses;
|
21
|
+
drop sequence membership_statuses_seq;
|
@@ -0,0 +1,111 @@
|
|
1
|
+
create table reference_types (
|
2
|
+
reference_type_id number(11) primary key,
|
3
|
+
type_label varchar2(50) default null,
|
4
|
+
abbreviation varchar2(50) default null,
|
5
|
+
description varchar2(50) default null
|
6
|
+
);
|
7
|
+
|
8
|
+
create sequence reference_types_seq
|
9
|
+
start with 1000;
|
10
|
+
|
11
|
+
create table reference_codes (
|
12
|
+
reference_type_id number(11),
|
13
|
+
reference_code number(11),
|
14
|
+
code_label varchar2(50) default null,
|
15
|
+
abbreviation varchar2(50) default null,
|
16
|
+
description varchar2(50) default null,
|
17
|
+
constraint reference_codes_pk primary key(reference_type_id, reference_code)
|
18
|
+
);
|
19
|
+
|
20
|
+
create table products (
|
21
|
+
id number(11) primary key,
|
22
|
+
name varchar2(50) default null
|
23
|
+
);
|
24
|
+
|
25
|
+
create sequence products_seq
|
26
|
+
start with 1000;
|
27
|
+
|
28
|
+
create table tariffs (
|
29
|
+
tariff_id number(11),
|
30
|
+
start_date date,
|
31
|
+
amount number(11) default null,
|
32
|
+
constraint tariffs_pk primary key(tariff_id, start_date)
|
33
|
+
);
|
34
|
+
|
35
|
+
create table product_tariffs (
|
36
|
+
product_id number(11),
|
37
|
+
tariff_id number(11),
|
38
|
+
tariff_start_date date,
|
39
|
+
constraint product_tariffs_pk primary key(product_id, tariff_id, tariff_start_date)
|
40
|
+
);
|
41
|
+
|
42
|
+
create table suburbs (
|
43
|
+
city_id number(11),
|
44
|
+
suburb_id number(11),
|
45
|
+
name varchar2(50) not null,
|
46
|
+
constraint suburbs_pk primary key(city_id, suburb_id)
|
47
|
+
);
|
48
|
+
|
49
|
+
create table streets (
|
50
|
+
id number(11) primary key,
|
51
|
+
city_id number(11) not null,
|
52
|
+
suburb_id number(11) not null,
|
53
|
+
name varchar2(50) not null
|
54
|
+
);
|
55
|
+
|
56
|
+
create sequence streets_seq
|
57
|
+
start with 1000;
|
58
|
+
|
59
|
+
create table users (
|
60
|
+
id number(11) primary key,
|
61
|
+
name varchar2(50) not null
|
62
|
+
);
|
63
|
+
|
64
|
+
create sequence users_seq
|
65
|
+
start with 1000;
|
66
|
+
|
67
|
+
create table articles (
|
68
|
+
id number(11) primary key,
|
69
|
+
name varchar2(50) not null
|
70
|
+
);
|
71
|
+
|
72
|
+
create sequence articles_seq
|
73
|
+
start with 1000;
|
74
|
+
|
75
|
+
|
76
|
+
create table readings (
|
77
|
+
id number(11) primary key,
|
78
|
+
user_id number(11) not null,
|
79
|
+
article_id number(11) not null,
|
80
|
+
rating number(11) not null
|
81
|
+
);
|
82
|
+
|
83
|
+
create sequence readings_seq
|
84
|
+
start with 1000;
|
85
|
+
|
86
|
+
|
87
|
+
create table groups (
|
88
|
+
id number(11) primary key,
|
89
|
+
name varchar2(50) not null
|
90
|
+
);
|
91
|
+
|
92
|
+
create sequence groups_seq
|
93
|
+
start with 1000;
|
94
|
+
|
95
|
+
|
96
|
+
create table memberships (
|
97
|
+
user_id number(11) not null,
|
98
|
+
group_id number(11) not null,
|
99
|
+
constraint memberships_pk primary key(user_id, group_id)
|
100
|
+
);
|
101
|
+
|
102
|
+
create table membership_statuses (
|
103
|
+
id number(11) primary key,
|
104
|
+
user_id number(11) not null,
|
105
|
+
group_id number(11) not null,
|
106
|
+
status varchar2(50) not null
|
107
|
+
);
|
108
|
+
|
109
|
+
create sequence membership_statuses_seq
|
110
|
+
start with 1000;
|
111
|
+
|
data/website/index.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>Composite Primary Keys</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/compositekeys"; return false'>
|
35
35
|
Get Version
|
36
|
-
<a href="http://rubyforge.org/projects/compositekeys" class="numbers">0.8.
|
36
|
+
<a href="http://rubyforge.org/projects/compositekeys" class="numbers">0.8.3</a>
|
37
37
|
</div>
|
38
38
|
<h1>→ Ruby on Rails</h1>
|
39
39
|
|
@@ -141,7 +141,7 @@ throughout your application. Just like a normal ActiveRecord.</p>
|
|
141
141
|
<h2>Other tricks</h2>
|
142
142
|
|
143
143
|
|
144
|
-
<
|
144
|
+
<h3>Pass a list of composite ids to the <code>#find</code> method</h3>
|
145
145
|
|
146
146
|
|
147
147
|
<p><pre class="syntax"><span class="constant">Membership</span><span class="punct">.</span><span class="ident">find</span> <span class="punct">[</span><span class="number">1</span><span class="punct">,</span><span class="number">1</span><span class="punct">],</span> <span class="punct">[</span><span class="number">2</span><span class="punct">,</span><span class="number">1</span><span class="punct">]</span>
|
@@ -157,6 +157,31 @@ throughout your application. Just like a normal ActiveRecord.</p>
|
|
157
157
|
<p><pre class="syntax"><span class="constant">MembershipStatus</span><span class="punct">.</span><span class="ident">find</span><span class="punct">(</span><span class="symbol">:first</span><span class="punct">).</span><span class="ident">memberships</span><span class="punct">.</span><span class="ident">count</span> <span class="comment"># => 1</span></pre></p>
|
158
158
|
|
159
159
|
|
160
|
+
<h3>Routes with Rails</h3>
|
161
|
+
|
162
|
+
|
163
|
+
<p>From Pete Sumskas:</p>
|
164
|
+
|
165
|
+
|
166
|
+
<blockquote>
|
167
|
+
I ran into one problem that I didn’t see mentioned on <a href="http://groups.google.com/group/compositekeys">this list</a> –
|
168
|
+
and I didn’t see any information about what I should do to address it in the
|
169
|
+
documentation (might have missed it).
|
170
|
+
|
171
|
+
The problem was that the urls being generated for a ‘show’ action (for
|
172
|
+
example) had a syntax like:
|
173
|
+
|
174
|
+
<pre>/controller/show/123000,Bu70</pre>
|
175
|
+
|
176
|
+
for a two-field composite PK. The default routing would not match that,
|
177
|
+
so after working out how to do the routing I added:
|
178
|
+
|
179
|
+
<pre class="syntax"><span class="ident">map</span><span class="punct">.</span><span class="ident">connect</span> <span class="punct">'</span><span class="string">:controller/:action/:id</span><span class="punct">',</span> <span class="symbol">:id</span> <span class="punct">=></span> <span class="punct">/</span><span class="regex"><span class="escape">\w</span>+(,<span class="escape">\w</span>+)*</span><span class="punct">/</span></pre>
|
180
|
+
|
181
|
+
to my <code>route.rb</code> file.
|
182
|
+
|
183
|
+
</blockquote>
|
184
|
+
|
160
185
|
<p><a name="dbs"></a></p>
|
161
186
|
|
162
187
|
|
@@ -189,8 +214,8 @@ throughout your application. Just like a normal ActiveRecord.</p>
|
|
189
214
|
</tr>
|
190
215
|
<tr>
|
191
216
|
<td>oracle </td>
|
192
|
-
<td><span class=
|
193
|
-
<td><span class=
|
217
|
+
<td><span class=success><span class="caps">YES</span></span> (new 0.8.2)</td>
|
218
|
+
<td><span class=success><span class="caps">YES</span></span> (<a href="mailto:compositekeys@googlegroups.com?subject=Oracle+is+working">Yes!</a> or <a href="mailto:compositekeys@googlegroups.com?subject=Oracle+is+failing">No…</a>)</td>
|
194
219
|
</tr>
|
195
220
|
<tr>
|
196
221
|
<td>sqlserver </td>
|
@@ -227,6 +252,12 @@ throughout your application. Just like a normal ActiveRecord.</p>
|
|
227
252
|
|
228
253
|
|
229
254
|
|
255
|
+
<h3>Thanks go to…</h3>
|
256
|
+
|
257
|
+
|
258
|
+
<p><strong>Darrin Holst</strong> – for Oracle unit tests and calculations support</p>
|
259
|
+
|
260
|
+
|
230
261
|
<h2>Dr Nic’s Blog</h2>
|
231
262
|
|
232
263
|
|
@@ -251,7 +282,7 @@ other stories and things.</p>
|
|
251
282
|
|
252
283
|
<p>Comments are welcome. Send an email to <a href="mailto:drnicwilliams@gmail.com">Dr Nic Williams</a>.</p>
|
253
284
|
<p class="coda">
|
254
|
-
<a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>,
|
285
|
+
<a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 3rd May 2007<br>
|
255
286
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
256
287
|
</p>
|
257
288
|
</div>
|
data/website/index.txt
CHANGED
@@ -78,7 +78,7 @@ throughout your application. Just like a normal ActiveRecord.
|
|
78
78
|
|
79
79
|
h2. Other tricks
|
80
80
|
|
81
|
-
Pass a list of composite ids to the <code>#find</code> method
|
81
|
+
h3. Pass a list of composite ids to the <code>#find</code> method
|
82
82
|
|
83
83
|
<pre syntax="ruby">Membership.find [1,1], [2,1]
|
84
84
|
=> [
|
@@ -90,6 +90,29 @@ Perform <code>#count</code> operations
|
|
90
90
|
|
91
91
|
<pre syntax="ruby">MembershipStatus.find(:first).memberships.count # => 1</pre>
|
92
92
|
|
93
|
+
h3. Routes with Rails
|
94
|
+
|
95
|
+
From Pete Sumskas:
|
96
|
+
|
97
|
+
<blockquote>
|
98
|
+
I ran into one problem that I didn't see mentioned on "this list":http://groups.google.com/group/compositekeys -
|
99
|
+
and I didn't see any information about what I should do to address it in the
|
100
|
+
documentation (might have missed it).
|
101
|
+
|
102
|
+
The problem was that the urls being generated for a 'show' action (for
|
103
|
+
example) had a syntax like:
|
104
|
+
|
105
|
+
<pre>/controller/show/123000,Bu70</pre>
|
106
|
+
|
107
|
+
for a two-field composite PK. The default routing would not match that,
|
108
|
+
so after working out how to do the routing I added:
|
109
|
+
|
110
|
+
<pre syntax="ruby">map.connect ':controller/:action/:id', :id => /\w+(,\w+)*/</pre>
|
111
|
+
|
112
|
+
to my <code>route.rb</code> file.
|
113
|
+
|
114
|
+
</blockquote>
|
115
|
+
|
93
116
|
<a name="dbs"></a>
|
94
117
|
|
95
118
|
h2. Which databases?
|
@@ -101,7 +124,7 @@ A suite of unit tests have been run on the following databases supported by Acti
|
|
101
124
|
|mysql |<span class=success>YES</span>|<span class=unknown>???</span> ("Yes!":mailto:compositekeys@googlegroups.com?subject=Mysql+is+working or "No...":mailto:compositekeys@googlegroups.com?subject=Mysql+is+failing)|
|
102
125
|
|sqlite3 |<span class=success>YES</span> (new 0.8.0)|<span class=unknown>???</span> ("Yes!":mailto:compositekeys@googlegroups.com?subject=Sqlite3+is+working or "No...":mailto:compositekeys@googlegroups.com?subject=Sqlite3+is+failing)|
|
103
126
|
|postgresql|<span class=success>YES</span> (new 0.8.0)|<span class=unknown>???</span> ("Yes!":mailto:compositekeys@googlegroups.com?subject=Postgresql+is+working or "No...":mailto:compositekeys@googlegroups.com?subject=Postgresql+is+failing)|
|
104
|
-
|oracle |<span class=
|
127
|
+
|oracle |<span class=success>YES</span> (new 0.8.2)|<span class=success>YES</span> ("Yes!":mailto:compositekeys@googlegroups.com?subject=Oracle+is+working or "No...":mailto:compositekeys@googlegroups.com?subject=Oracle+is+failing)|
|
105
128
|
|sqlserver |<span class=unknown>???</span> ("I can help":mailto:compositekeys@googlegroups.com?subject=Help+with+SQLServer)|<span class=unknown>???</span> ("Yes!":mailto:compositekeys@googlegroups.com?subject=SQLServer+is+working or "No...":mailto:compositekeys@googlegroups.com?subject=SQLServer+is+failing)|
|
106
129
|
|db2 |<span class=unknown>???</span> ("I can help":mailto:compositekeys@googlegroups.com?subject=Help+with+DB2)|<span class=unknown>???</span> ("Yes!":mailto:compositekeys@googlegroups.com?subject=DB2+is+working or "No...":mailto:compositekeys@googlegroups.com?subject=DB2+is+failing)|
|
107
130
|
|firebird |<span class=unknown>???</span> ("I can help":mailto:compositekeys@googlegroups.com?subject=Help+with+Firebird)|<span class=unknown>???</span> ("Yes!":mailto:compositekeys@googlegroups.com?subject=Firebird+is+working or "No...":mailto:compositekeys@googlegroups.com?subject=Firebird+is+failing)|
|
@@ -109,6 +132,10 @@ A suite of unit tests have been run on the following databases supported by Acti
|
|
109
132
|
|openbase |<span class=unknown>???</span> ("I can help":mailto:compositekeys@googlegroups.com?subject=Help+with+Openbase)|<span class=unknown>???</span> ("Yes!":mailto:compositekeys@googlegroups.com?subject=Openbase+is+working or "No...":mailto:compositekeys@googlegroups.com?subject=Openbase+is+failing)|
|
110
133
|
|frontbase |<span class=unknown>???</span> ("I can help":mailto:compositekeys@googlegroups.com?subject=Help+with+Frontbase)|<span class=unknown>???</span> ("Yes!":mailto:compositekeys@googlegroups.com?subject=Frontbase+is+working or "No...":mailto:compositekeys@googlegroups.com?subject=Frontbase+is+failing)|
|
111
134
|
|
135
|
+
h3. Thanks go to...
|
136
|
+
|
137
|
+
*Darrin Holst* - for Oracle unit tests and calculations support
|
138
|
+
|
112
139
|
h2. Dr Nic's Blog
|
113
140
|
|
114
141
|
"http://www.drnicwilliams.com":http://www.drnicwilliams.com - for future announcements and
|
data/website/version-raw.js
CHANGED
data/website/version.js
CHANGED
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: composite_primary_keys
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.8.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.8.3
|
7
|
+
date: 2007-05-03 00:00:00 +02:00
|
8
8
|
summary: Composite key support for ActiveRecords
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -56,6 +56,8 @@ files:
|
|
56
56
|
- test/fixtures/article.rb
|
57
57
|
- test/fixtures/articles.yml
|
58
58
|
- test/fixtures/db_definitions/mysql.sql
|
59
|
+
- test/fixtures/db_definitions/oracle.drop.sql
|
60
|
+
- test/fixtures/db_definitions/oracle.sql
|
59
61
|
- test/fixtures/db_definitions/postgresql.sql
|
60
62
|
- test/fixtures/db_definitions/sqlite.sql
|
61
63
|
- test/fixtures/group.rb
|