composite_primary_keys 0.8.0 → 0.8.2

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 ADDED
@@ -0,0 +1,21 @@
1
+ *** 0.8.2 / 2007-4-11
2
+
3
+ + 1 major enhancement:
4
+ + Oracle unit tests!! [Darrin Holst]
5
+ + And they work too
6
+
7
+ *** 0.8.1 / 2007-4-10
8
+
9
+ + 1 bug fix:
10
+ + Fixed the distinct(count) for oracle (removed 'as')
11
+
12
+ *** 0.8.0 / 2007-4-6
13
+
14
+ + 1 major enhancement:
15
+ + Support for calcualtions on associations
16
+ + 2 new DB supported:
17
+ + Tests run on sqlite
18
+ + Tests run on postgresql
19
+ + History.txt to keep track of changes like these
20
+ + Using Hoe for Rakefile
21
+ + Website generator rake tasks
data/Manifest.txt CHANGED
@@ -1,4 +1,5 @@
1
1
  CHANGELOG
2
+ History.txt
2
3
  Manifest.txt
3
4
  README
4
5
  Rakefile
@@ -8,6 +9,7 @@ lib/composite_primary_keys/associations.rb
8
9
  lib/composite_primary_keys/base.rb
9
10
  lib/composite_primary_keys/calculations.rb
10
11
  lib/composite_primary_keys/composite_arrays.rb
12
+ lib/composite_primary_keys/connection_adapters/oracle_adapter.rb
11
13
  lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb
12
14
  lib/composite_primary_keys/fixtures.rb
13
15
  lib/composite_primary_keys/reflection.rb
data/Rakefile CHANGED
@@ -46,7 +46,7 @@ hoe = Hoe.new(GEM_NAME, VERSION) do |p|
46
46
  p.clean_globs = CLEAN #An array of file patterns to delete on clean.
47
47
 
48
48
  # == Optional
49
- #p.changes - A description of the release's latest changes.
49
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
50
50
  p.extra_deps = [['activerecord', '>= 1.14.3']] #An array of rubygem dependencies.
51
51
  #p.spec_extras - A hash of extra values to set in the gemspec.
52
52
  end
@@ -118,6 +118,20 @@ end
118
118
  desc 'Rebuild the PostgreSQL test databases'
119
119
  task :rebuild_postgresql_databases => [:drop_postgresql_databases, :build_postgresql_databases]
120
120
 
121
+ desc 'Build the Oracle test databases'
122
+ task :build_oracle_databases do
123
+ puts File.join(SCHEMA_PATH, 'oracle.sql')
124
+ sh %( sqlplus holstdl/holstdl@test < #{File.join(SCHEMA_PATH, 'oracle.sql')} )
125
+ end
126
+
127
+ desc 'Drop the Oracle test databases'
128
+ task :drop_oracle_databases do
129
+ sh %( sqlplus holstdl/holstdl@test < #{File.join(SCHEMA_PATH, 'oracle.drop.sql')} )
130
+ end
131
+
132
+ desc 'Rebuild the Oracle test databases'
133
+ task :rebuild_oracle_databases => [:drop_oracle_databases, :build_oracle_databases]
134
+
121
135
  desc 'Generate website files'
122
136
  task :website_generate do
123
137
  sh %{ ruby scripts/txt2html website/index.txt > website/index.html }
@@ -131,9 +145,8 @@ task :website_upload do
131
145
  host = "#{config["username"]}@rubyforge.org"
132
146
  remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/"
133
147
  local_dir = 'website'
134
- sh %{rsync -av --delete #{local_dir}/ #{host}:#{remote_dir}}
148
+ sh %{rsync -av #{local_dir}/ #{host}:#{remote_dir}}
135
149
  end
136
150
 
137
151
  desc 'Generate and upload website files'
138
- task :website => [:website_generate, :website_upload] do
139
- end
152
+ task :website => [:website_generate, :website_upload]
@@ -203,7 +203,7 @@ module ActiveRecord::Associations::ClassMethods
203
203
  end
204
204
 
205
205
  def full_keys(table_name, keys)
206
- keys.collect {|key| "#{table_name}.#{key}"}.join(CompositePrimaryKeys::ID_SEP)
206
+ keys.is_a?(Array) ? keys.collect {|key| "#{table_name}.#{key}"}.join(CompositePrimaryKeys::ID_SEP) : "#{table_name}.#{keys}"
207
207
  end
208
208
 
209
209
  def composite_join_clause(full_keys1, full_keys2)
@@ -54,7 +54,7 @@ module CompositePrimaryKeys
54
54
 
55
55
  sql << " ORDER BY #{options[:order]} " if options[:order]
56
56
  add_limit!(sql, options, scope)
57
- sql << ') as w1' if use_workaround
57
+ sql << ') w1' if use_workaround # assign a dummy table name as required for postgresql
58
58
  sql
59
59
  end
60
60
  end
@@ -0,0 +1,11 @@
1
+ module ActiveRecord
2
+ module ConnectionAdapters
3
+ class OracleAdapter < AbstractAdapter
4
+
5
+ # This mightn't be in Core, but count(distinct x,y) doesn't work for me
6
+ def supports_count_distinct? #:nodoc:
7
+ false
8
+ end
9
+ end
10
+ end
11
+ end
@@ -2,7 +2,7 @@ module CompositePrimaryKeys
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 8
5
- TINY = 0
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -1,23 +1,16 @@
1
- print "Using Oracle\n"
2
- require_dependency 'fixtures/course'
1
+ print "Using native Oracle\n"
3
2
  require 'logger'
4
3
 
5
- ActiveRecord::Base.logger = Logger.new STDOUT
6
- ActiveRecord::Base.logger.level = Logger::WARN
4
+ ActiveRecord::Base.logger = Logger.new("debug.log")
7
5
 
8
- # Set these to your database connection strings
9
- db = ENV['ARUNIT_DB'] || 'ruby_ut'
6
+ db1 = 'composite_primary_keys_unittest'
10
7
 
11
- ActiveRecord::Base.establish_connection(
12
- :adapter => 'oracle',
13
- :username => 'ruby_ut',
14
- :password => 'ruby_ut1',
15
- :database => db
16
- )
8
+ connection_options = {
9
+ :adapter => 'oci',
10
+ :username => 'holstdl',
11
+ :password => 'holstdl',
12
+ :host => 'test'
13
+ }
17
14
 
18
- Course.establish_connection(
19
- :adapter => 'oracle',
20
- :username => 'ruby_ut',
21
- :password => 'ruby_ut1',
22
- :database => db
23
- )
15
+ ActiveRecord::Base.configurations = { db1 => connection_options }
16
+ ActiveRecord::Base.establish_connection(connection_options)
@@ -1,8 +1,10 @@
1
1
  santiago-cpk:
2
+ id: 1
2
3
  user_id: 1
3
4
  group_id: 1
4
5
  status: Active
5
6
  drnic-cpk:
7
+ id: 2
6
8
  user_id: 2
7
9
  group_id: 1
8
10
  status: Owner
@@ -72,6 +72,12 @@ class TestAssociations < Test::Unit::TestCase
72
72
  "Incorrect number of product_tariffs returnedturned"
73
73
  end
74
74
 
75
+ def test_find_includes_product
76
+ assert @product_tariffs = ProductTariff.find(:all, :include => :product)
77
+ assert_equal 3, @product_tariffs.length
78
+ assert_not_nil @product_tariffs.first.instance_variable_get('@product'), '@product not set'
79
+ end
80
+
75
81
  def XXX_test_find_includes_extended
76
82
  # TODO - what's the correct syntax?
77
83
  assert @products = Product.find(:all, :include => {:product_tariffs => :tariffs})
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.0</a>
36
+ <a href="http://rubyforge.org/projects/compositekeys" class="numbers">0.8.2</a>
37
37
  </div>
38
38
  <h1>&#x2192; Ruby on Rails</h1>
39
39
 
@@ -1,3 +1,3 @@
1
1
  // Announcement JS file
2
- var version = "0.8.0";
2
+ var version = "0.8.2";
3
3
  MagicAnnouncement.show('compositekeys', version);
data/website/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // Version JS file
2
- var version = "0.8.0";
2
+ var version = "0.8.2";
3
3
 
4
4
  document.write(" - " + version);
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.0
7
- date: 2007-04-07 00:00:00 +02:00
6
+ version: 0.8.2
7
+ date: 2007-04-11 00:00:00 +02:00
8
8
  summary: Composite key support for ActiveRecords
9
9
  require_paths:
10
10
  - lib
@@ -30,6 +30,7 @@ authors:
30
30
  - Dr Nic Williams
31
31
  files:
32
32
  - CHANGELOG
33
+ - History.txt
33
34
  - Manifest.txt
34
35
  - README
35
36
  - Rakefile
@@ -39,6 +40,7 @@ files:
39
40
  - lib/composite_primary_keys/base.rb
40
41
  - lib/composite_primary_keys/calculations.rb
41
42
  - lib/composite_primary_keys/composite_arrays.rb
43
+ - lib/composite_primary_keys/connection_adapters/oracle_adapter.rb
42
44
  - lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb
43
45
  - lib/composite_primary_keys/fixtures.rb
44
46
  - lib/composite_primary_keys/reflection.rb