composite_primary_keys 2.3.5.1 → 3.0.0.b2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +26 -0
- data/README.txt +1 -1
- data/Rakefile +41 -51
- data/lib/composite_primary_keys.rb +19 -7
- data/lib/composite_primary_keys/association_preload.rb +75 -170
- data/lib/composite_primary_keys/associations.rb +98 -400
- data/lib/composite_primary_keys/associations/association_proxy.rb +32 -0
- data/lib/composite_primary_keys/associations/has_and_belongs_to_many_association.rb +30 -0
- data/lib/composite_primary_keys/associations/has_many_association.rb +72 -0
- data/lib/composite_primary_keys/associations/has_one_association.rb +19 -0
- data/lib/composite_primary_keys/associations/through_association_scope.rb +103 -0
- data/lib/composite_primary_keys/base.rb +148 -305
- data/lib/composite_primary_keys/calculations.rb +22 -64
- data/lib/composite_primary_keys/composite_arrays.rb +3 -10
- data/lib/composite_primary_keys/connection_adapters/abstract_adapter.rb +9 -0
- data/lib/composite_primary_keys/connection_adapters/oracle_enhanced_adapter.rb +17 -0
- data/lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb +1 -1
- data/lib/composite_primary_keys/finder_methods.rb +71 -0
- data/lib/composite_primary_keys/fixtures.rb +1 -1
- data/lib/composite_primary_keys/read.rb +25 -0
- data/lib/composite_primary_keys/reflection.rb +30 -10
- data/lib/composite_primary_keys/relation.rb +31 -0
- data/lib/composite_primary_keys/validations/uniqueness.rb +106 -66
- data/lib/composite_primary_keys/version.rb +4 -4
- data/scripts/console.rb +1 -1
- data/tasks/Rakefile.rb +13 -0
- data/tasks/databases/mysql.rake +11 -15
- data/tasks/databases/oracle.rake +10 -11
- data/tasks/databases/postgresql.rake +10 -13
- data/tasks/databases/sqlite3.rake +9 -9
- data/test/README_tests.txt +1 -45
- data/test/abstract_unit.rb +17 -14
- data/test/connections/connection_spec.rb +19 -0
- data/test/connections/databases.example.yml +11 -0
- data/test/connections/databases.yml +13 -0
- data/test/connections/native_mysql/connection.rb +10 -2
- data/test/connections/native_oracle/connection.rb +7 -4
- data/test/connections/native_oracle_enhanced/connection.rb +23 -0
- data/test/connections/native_postgresql/connection.rb +13 -5
- data/test/connections/native_sqlite/connection.rb +7 -3
- data/test/fixtures/article_group.rb +4 -0
- data/test/fixtures/article_groups.yml +7 -0
- data/test/fixtures/db_definitions/postgresql.sql +2 -1
- data/test/fixtures/debug.log +133 -0
- data/test/fixtures/dorm.rb +3 -0
- data/test/fixtures/dorms.yml +2 -0
- data/test/fixtures/kitchen_sink.rb +3 -0
- data/test/fixtures/kitchen_sinks.yml +5 -0
- data/test/fixtures/reference_codes.yml +2 -0
- data/test/fixtures/reference_type.rb +1 -1
- data/test/fixtures/restaurant.rb +6 -0
- data/test/fixtures/restaurants.yml +5 -0
- data/test/fixtures/restaurants_suburbs.yml +11 -0
- data/test/fixtures/room.rb +10 -0
- data/test/fixtures/room_assignment.rb +4 -0
- data/test/fixtures/room_assignments.yml +4 -0
- data/test/fixtures/room_attribute.rb +3 -0
- data/test/fixtures/room_attribute_assignment.rb +5 -0
- data/test/fixtures/room_attribute_assignments.yml +4 -0
- data/test/fixtures/room_attributes.yml +3 -0
- data/test/fixtures/rooms.yml +3 -0
- data/test/fixtures/seat.rb +5 -0
- data/test/fixtures/seats.yml +4 -0
- data/test/fixtures/student.rb +4 -0
- data/test/fixtures/students.yml +2 -0
- data/test/test_associations.rb +27 -50
- data/test/test_attributes.rb +15 -19
- data/test/test_composite_arrays.rb +2 -21
- data/test/test_create.rb +3 -3
- data/test/test_delete.rb +7 -20
- data/test/test_exists.rb +3 -7
- data/test/test_find.rb +0 -8
- data/test/test_ids.rb +3 -17
- data/test/test_polymorphic.rb +5 -4
- data/test/test_suite.rb +19 -0
- data/test/{test_tutorial_examle.rb → test_tutorial_example.rb} +0 -0
- metadata +110 -72
- data/Manifest.txt +0 -123
- data/lib/adapter_helper/base.rb +0 -63
- data/lib/adapter_helper/mysql.rb +0 -13
- data/lib/adapter_helper/oracle.rb +0 -12
- data/lib/adapter_helper/postgresql.rb +0 -13
- data/lib/adapter_helper/sqlite3.rb +0 -13
- data/lib/composite_primary_keys/migration.rb +0 -20
- data/local/database_connections.rb.sample +0 -12
- data/local/paths.rb.sample +0 -2
- data/local/tasks.rb.sample +0 -2
- data/tasks/activerecord_selection.rake +0 -43
- data/tasks/databases.rake +0 -12
- data/tasks/deployment.rake +0 -22
- data/tasks/local_setup.rake +0 -13
- data/test/test_dummy.rb +0 -28
- data/tmp/test.db +0 -0
- data/website/index.html +0 -195
- data/website/index.txt +0 -159
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -126
- data/website/template.js +0 -3
- data/website/template.rhtml +0 -53
- data/website/version-raw.js +0 -3
- data/website/version-raw.txt +0 -2
- data/website/version.js +0 -4
- data/website/version.txt +0 -3
data/scripts/console.rb
CHANGED
@@ -32,7 +32,7 @@ $LOAD_PATH.unshift 'lib'
|
|
32
32
|
|
33
33
|
begin
|
34
34
|
require 'local/paths'
|
35
|
-
$LOAD_PATH.unshift "#{ENV['EDGE_RAILS_DIR']}/
|
35
|
+
$LOAD_PATH.unshift "#{ENV['EDGE_RAILS_DIR']}/active_record/lib" if ENV['EDGE_RAILS_DIR']
|
36
36
|
$LOAD_PATH.unshift "#{ENV['EDGE_RAILS_DIR']}/activesupport/lib" if ENV['EDGE_RAILS_DIR']
|
37
37
|
rescue
|
38
38
|
end
|
data/tasks/Rakefile.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#require 'rake'
|
2
|
+
#require 'rake/testtask'
|
3
|
+
#
|
4
|
+
#require File.join(PROJECT_ROOT, 'test', 'connections', 'connection_spec')
|
5
|
+
#
|
6
|
+
## Set up test tasks
|
7
|
+
#for adapter in %w( mysql sqlite oracle oracle_enhanced postgresql ibm_db )
|
8
|
+
# Rake::TestTask.new("test_#{adapter}") do |t|
|
9
|
+
# t.libs << "test" << "test/connections/native_#{adapter}"
|
10
|
+
# t.pattern = "test/test_*.rb"
|
11
|
+
# t.verbose = true
|
12
|
+
# end
|
13
|
+
#nd
|
data/tasks/databases/mysql.rake
CHANGED
@@ -1,30 +1,26 @@
|
|
1
|
+
require File.join(PROJECT_ROOT, 'test', 'connections', 'connection_spec')
|
2
|
+
|
1
3
|
namespace :mysql do
|
2
4
|
desc 'Build the MySQL test databases'
|
3
5
|
task :build_databases => :load_connection do
|
4
|
-
|
5
|
-
options_str = ENV['cpk_adapter_options_str']
|
6
|
+
options_str = connection_string
|
6
7
|
# creates something like "-u#{username} -p#{password} -S#{socket}"
|
7
|
-
sh %{ mysqladmin #{options_str} create "#{
|
8
|
-
|
8
|
+
sh %{ mysqladmin #{options_str} create "#{SPEC['database']}" }
|
9
|
+
|
10
|
+
schema = File.join(PROJECT_ROOT, 'test', 'fixtures', 'db_definitions', 'mysql.sql')
|
11
|
+
sh %{ mysql #{options_str} "#{SPEC['database']}" < #{schema} }
|
9
12
|
end
|
10
13
|
|
11
14
|
desc 'Drop the MySQL test databases'
|
12
15
|
task :drop_databases => :load_connection do
|
13
|
-
options_str =
|
14
|
-
sh %{ mysqladmin #{options_str} -f drop "#{
|
16
|
+
options_str = connection_string
|
17
|
+
sh %{ mysqladmin #{options_str} -f drop "#{SPEC['database']}" }
|
15
18
|
end
|
16
19
|
|
17
20
|
desc 'Rebuild the MySQL test databases'
|
18
21
|
task :rebuild_databases => [:drop_databases, :build_databases]
|
19
22
|
|
20
23
|
task :load_connection do
|
21
|
-
require File.join(PROJECT_ROOT,
|
22
|
-
spec = AdapterHelper::MySQL.load_connection_from_env
|
23
|
-
options = {}
|
24
|
-
options['u'] = spec[:username] if spec[:username]
|
25
|
-
options['p'] = spec[:password] if spec[:password]
|
26
|
-
options['S'] = spec[:sock] if spec[:sock]
|
27
|
-
options_str = options.map { |key, value| "-#{key}#{value}" }.join(" ")
|
28
|
-
ENV['cpk_adapter_options_str'] = options_str
|
24
|
+
require File.join(PROJECT_ROOT, "test", "connections", "native_mysql", "connection")
|
29
25
|
end
|
30
|
-
end
|
26
|
+
end
|
data/tasks/databases/oracle.rake
CHANGED
@@ -1,25 +1,24 @@
|
|
1
|
+
require File.join(PROJECT_ROOT, 'test', 'connections', 'connection_spec')
|
2
|
+
|
1
3
|
namespace :oracle do
|
2
4
|
desc 'Build the Oracle test databases'
|
3
|
-
task :build_databases => :load_connection do
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
task :build_databases => :load_connection do
|
6
|
+
options_str = connection_string
|
7
|
+
|
8
|
+
schema = File.join(PROJECT_ROOT, 'test', 'fixtures', 'db_definitions', 'oracle.sql')
|
9
|
+
sh %( sqlplus #{options_str} < #{schema} )
|
7
10
|
end
|
8
11
|
|
9
12
|
desc 'Drop the Oracle test databases'
|
10
13
|
task :drop_databases => :load_connection do
|
11
|
-
|
12
|
-
options_str = ENV['cpk_adapter_options_str']
|
14
|
+
options_str = connection_string
|
13
15
|
sh %( sqlplus #{options_str} < #{File.join(SCHEMA_PATH, 'oracle.drop.sql')} )
|
14
16
|
end
|
15
17
|
|
16
18
|
desc 'Rebuild the Oracle test databases'
|
17
19
|
task :rebuild_databases => [:drop_databases, :build_databases]
|
18
|
-
|
20
|
+
|
19
21
|
task :load_connection do
|
20
|
-
require File.join(PROJECT_ROOT,
|
21
|
-
spec = AdapterHelper::Oracle.load_connection_from_env
|
22
|
-
ENV['cpk_adapter_options_str'] = "#{spec[:username]}/#{spec[:password]}@#{spec[:host]}"
|
22
|
+
require File.join(PROJECT_ROOT, "test", "connections", "native_oracle", "connection")
|
23
23
|
end
|
24
|
-
|
25
24
|
end
|
@@ -1,26 +1,23 @@
|
|
1
|
+
require File.join(PROJECT_ROOT, 'test', 'connections', 'connection_spec')
|
2
|
+
|
1
3
|
namespace :postgresql do
|
2
4
|
desc 'Build the PostgreSQL test databases'
|
3
|
-
task :build_databases => :load_connection do
|
4
|
-
sh %{ createdb "#{
|
5
|
-
|
5
|
+
task :build_databases => :load_connection do
|
6
|
+
sh %{ createdb #{connection_string} "#{SPEC['database']}" }
|
7
|
+
|
8
|
+
schema = File.join(PROJECT_ROOT, 'test', 'fixtures', 'db_definitions', 'postgresql.sql')
|
9
|
+
sh %{ psql #{connection_string} "#{SPEC['database']}" -f #{schema} }
|
6
10
|
end
|
7
11
|
|
8
12
|
desc 'Drop the PostgreSQL test databases'
|
9
13
|
task :drop_databases => :load_connection do
|
10
|
-
sh %{ dropdb "#{
|
14
|
+
sh %{ dropdb #{connection_string} "#{SPEC['database']}" }
|
11
15
|
end
|
12
16
|
|
13
17
|
desc 'Rebuild the PostgreSQL test databases'
|
14
18
|
task :rebuild_databases => [:drop_databases, :build_databases]
|
15
19
|
|
16
20
|
task :load_connection do
|
17
|
-
require File.join(PROJECT_ROOT,
|
18
|
-
spec = AdapterHelper::Postgresql.load_connection_from_env
|
19
|
-
options = {}
|
20
|
-
options['u'] = spec[:username] if spec[:username]
|
21
|
-
options['p'] = spec[:password] if spec[:password]
|
22
|
-
options_str = options.map { |key, value| "-#{key}#{value}" }.join(" ")
|
23
|
-
ENV['cpk_adapter_options_str'] = options_str
|
21
|
+
require File.join(PROJECT_ROOT, "test", "connections", "native_postgresql", "connection")
|
24
22
|
end
|
25
|
-
end
|
26
|
-
|
23
|
+
end
|
@@ -1,19 +1,21 @@
|
|
1
|
+
require File.join(PROJECT_ROOT, 'test', 'connections', 'connection_spec')
|
2
|
+
|
1
3
|
namespace :sqlite3 do
|
2
4
|
desc 'Build the sqlite test databases'
|
3
|
-
task :build_databases => :load_connection do
|
4
|
-
|
5
|
-
dbfile = File.join(PROJECT_ROOT,
|
5
|
+
task :build_databases => :load_connection do
|
6
|
+
schema = File.join(PROJECT_ROOT, 'test', 'fixtures', 'db_definitions', 'sqlite.sql')
|
7
|
+
dbfile = File.join(PROJECT_ROOT, connection_string)
|
6
8
|
cmd = "mkdir -p #{File.dirname(dbfile)}"
|
7
9
|
puts cmd
|
8
10
|
sh %{ #{cmd} }
|
9
|
-
cmd = "sqlite3 #{dbfile} < #{
|
11
|
+
cmd = "sqlite3 #{dbfile} < #{schema}"
|
10
12
|
puts cmd
|
11
13
|
sh %{ #{cmd} }
|
12
14
|
end
|
13
15
|
|
14
16
|
desc 'Drop the sqlite test databases'
|
15
17
|
task :drop_databases => :load_connection do
|
16
|
-
dbfile =
|
18
|
+
dbfile = connection_string
|
17
19
|
sh %{ rm -f #{dbfile} }
|
18
20
|
end
|
19
21
|
|
@@ -21,8 +23,6 @@ namespace :sqlite3 do
|
|
21
23
|
task :rebuild_databases => [:drop_databases, :build_databases]
|
22
24
|
|
23
25
|
task :load_connection do
|
24
|
-
require File.join(PROJECT_ROOT,
|
25
|
-
spec = AdapterHelper::Sqlite3.load_connection_from_env
|
26
|
-
ENV['cpk_adapter_options_str'] = spec[:dbfile]
|
26
|
+
require File.join(PROJECT_ROOT, "test", "connections", "native_sqlite3", "connection")
|
27
27
|
end
|
28
|
-
end
|
28
|
+
end
|
data/test/README_tests.txt
CHANGED
@@ -10,7 +10,7 @@ There are tests available for the following adapters:
|
|
10
10
|
* postgresql
|
11
11
|
* sqlite
|
12
12
|
|
13
|
-
To run the tests for on of the adapters
|
13
|
+
To run the tests for on of the adapters follow these steps (using mysql in the example):
|
14
14
|
|
15
15
|
* rake -T | grep mysql
|
16
16
|
|
@@ -21,47 +21,3 @@ To run the tests for on of the adapters, follow these steps (using mysql in the
|
|
21
21
|
|
22
22
|
* rake mysql:build_databases
|
23
23
|
* rake test_mysql
|
24
|
-
|
25
|
-
== Testing against different ActiveRecord versions (or Edge Rails)
|
26
|
-
|
27
|
-
ActiveRecord is a RubyGem within Rails, and is constantly being improved/changed on
|
28
|
-
its repository (http://dev.rubyonrails.org). These changes may create errors for the CPK
|
29
|
-
gem. So, we need a way to test CPK against Edge Rails, as well as officially released RubyGems.
|
30
|
-
|
31
|
-
The default test (as above) uses the latest RubyGem in your cache.
|
32
|
-
|
33
|
-
You can select an older RubyGem version by running the following:
|
34
|
-
|
35
|
-
* rake ar:set VERSION=1.14.4 test_mysql
|
36
|
-
|
37
|
-
== Edge Rails
|
38
|
-
|
39
|
-
Before you can test CPK against Edge Rails, you must checkout a copy of edge rails somewhere (see http://dev.rubyonrails.org for for examples)
|
40
|
-
|
41
|
-
* cd /path/to/gems
|
42
|
-
* svn co http://svn.rubyonrails.org/rails/trunk rails
|
43
|
-
|
44
|
-
Say the rails folder is /path/to/gems/rails
|
45
|
-
|
46
|
-
Three ways to run CPK tests for Edge Rails:
|
47
|
-
|
48
|
-
i) Run:
|
49
|
-
|
50
|
-
EDGE_RAILS_DIR=/path/to/gems/rails rake ar:edge test_mysql
|
51
|
-
|
52
|
-
ii) In your .profile, set the environment variable EDGE_RAILS_DIR=/path/to/gems/rails,
|
53
|
-
and once you reload your profile, run:
|
54
|
-
|
55
|
-
rake ar:edge test_mysql
|
56
|
-
|
57
|
-
iii) Store the path in local/paths.rb. Run:
|
58
|
-
|
59
|
-
cp local/paths.rb.sample local/paths.rb
|
60
|
-
# Now set ENV['EDGE_RAILS_DIR']=/path/to/gems/rails
|
61
|
-
rake ar:edge test_mysql
|
62
|
-
|
63
|
-
These are all variations of the same theme:
|
64
|
-
|
65
|
-
* Set the environment variable EDGE_RAILS_DIR to the path to Rails (which contains the activerecord/lib folder)
|
66
|
-
* Run: rake ar:edge test_<adapter>
|
67
|
-
|
data/test/abstract_unit.rb
CHANGED
@@ -1,20 +1,25 @@
|
|
1
|
-
|
1
|
+
dir = File.dirname(__FILE__)
|
2
|
+
PROJECT_ROOT = File.expand_path(File.join(dir, '..'))
|
2
3
|
|
4
|
+
adapter ||= 'postgresql'
|
5
|
+
|
6
|
+
require 'pp'
|
3
7
|
require 'test/unit'
|
4
8
|
require 'hash_tricks'
|
5
9
|
require 'rubygems'
|
6
10
|
require 'active_record'
|
7
11
|
require 'active_record/fixtures'
|
8
|
-
|
9
|
-
|
10
|
-
rescue MissingSourceFile => e
|
11
|
-
adapter = 'postgresql' #'sqlite'
|
12
|
-
require "#{File.dirname(__FILE__)}/connections/native_#{adapter}/connection"
|
13
|
-
end
|
12
|
+
require File.join(PROJECT_ROOT, 'test', 'connections', 'connection_spec')
|
13
|
+
require File.join(PROJECT_ROOT, "test", "connections", "native_#{adapter}", "connection")
|
14
14
|
require 'composite_primary_keys'
|
15
15
|
|
16
|
+
# Tell ActiveRecord where to find models
|
17
|
+
ActiveSupport::Dependencies.autoload_paths << File.join(PROJECT_ROOT, 'test', 'fixtures')
|
18
|
+
|
16
19
|
QUOTED_TYPE = ActiveRecord::Base.connection.quote_column_name('type') unless Object.const_defined?(:QUOTED_TYPE)
|
17
20
|
|
21
|
+
ActiveRecord::Base.configurations[:test] = CompositePrimaryKeys::ConnectionSpec[adapter]
|
22
|
+
|
18
23
|
class ActiveSupport::TestCase #:nodoc:
|
19
24
|
include ActiveRecord::TestFixtures
|
20
25
|
|
@@ -52,10 +57,12 @@ class ActiveSupport::TestCase #:nodoc:
|
|
52
57
|
end
|
53
58
|
|
54
59
|
cattr_accessor :classes
|
55
|
-
|
60
|
+
|
61
|
+
protected
|
56
62
|
|
57
63
|
def testing_with(&block)
|
58
|
-
classes.keys.each do
|
64
|
+
classes.keys.each do |key_test|
|
65
|
+
@key_test = key_test
|
59
66
|
@klass_info = classes[@key_test]
|
60
67
|
@klass, @primary_keys = @klass_info[:class], @klass_info[:primary_keys]
|
61
68
|
order = @klass.primary_key.is_a?(String) ? @klass.primary_key : @klass.primary_key.join(',')
|
@@ -69,10 +76,6 @@ protected
|
|
69
76
|
composite? ? ids.to_composite_ids : ids.first
|
70
77
|
end
|
71
78
|
|
72
|
-
def first_id_str
|
73
|
-
composite? ? first_id.join(CompositePrimaryKeys::ID_SEP) : first_id.to_s
|
74
|
-
end
|
75
|
-
|
76
79
|
def composite?
|
77
80
|
@key_test != :single
|
78
81
|
end
|
@@ -92,5 +95,5 @@ ActiveRecord::Base.connection.class.class_eval do
|
|
92
95
|
end
|
93
96
|
end
|
94
97
|
|
95
|
-
|
98
|
+
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
96
99
|
#ActiveRecord::Base.colorize_logging = false
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module CompositePrimaryKeys
|
4
|
+
class ConnectionSpec
|
5
|
+
def self.[](adapter)
|
6
|
+
config[adapter.to_s]
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def self.config
|
12
|
+
@config ||= begin
|
13
|
+
path = File.join(PROJECT_ROOT, 'test', 'connections', 'databases.yml')
|
14
|
+
puts path
|
15
|
+
YAML.load_file(path)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -2,12 +2,20 @@ print "Using native MySQL\n"
|
|
2
2
|
require 'fileutils'
|
3
3
|
require 'logger'
|
4
4
|
require 'adapter_helper/mysql'
|
5
|
+
require 'active_record'
|
5
6
|
|
6
7
|
log_path = File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. .. log]))
|
7
8
|
FileUtils.mkdir_p log_path
|
8
|
-
puts "Logging to #{log_path}/debug.log"
|
9
9
|
ActiveRecord::Base.logger = Logger.new("#{log_path}/debug.log")
|
10
10
|
|
11
|
-
|
11
|
+
def connection_string
|
12
|
+
options = {}
|
13
|
+
options['u'] = SPEC['username'] if SPEC['username']
|
14
|
+
options['p'] = SPEC['password'] if SPEC['password']
|
15
|
+
options['S'] = SPEC['sock'] if SPEC['sock']
|
16
|
+
options.map { |key, value| "-#{key} #{value}" }.join(" ")
|
17
|
+
end
|
18
|
+
|
19
|
+
# Adapter config setup in locals/database_connections.rb
|
12
20
|
connection_options = AdapterHelper::MySQL.load_connection_from_env
|
13
21
|
ActiveRecord::Base.establish_connection(connection_options)
|
@@ -2,13 +2,16 @@ print "Using native Oracle\n"
|
|
2
2
|
require 'fileutils'
|
3
3
|
require 'logger'
|
4
4
|
require 'adapter_helper/oracle'
|
5
|
+
require 'active_record'
|
5
6
|
|
6
7
|
log_path = File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. .. log]))
|
7
8
|
FileUtils.mkdir_p log_path
|
8
|
-
puts "Logging to #{log_path}/debug.log"
|
9
9
|
ActiveRecord::Base.logger = Logger.new("#{log_path}/debug.log")
|
10
10
|
|
11
|
+
def connection_string
|
12
|
+
"#{connection_SPEC['username']}/#{connection_SPEC['password']}@#{connection_SPEC['host']}"
|
13
|
+
end
|
14
|
+
|
11
15
|
# Adapter config setup in locals/database_connections.rb
|
12
|
-
|
13
|
-
|
14
|
-
ActiveRecord::Base.establish_connection(connection_options)
|
16
|
+
spec = CompositePrimaryKeys::ConnectionSpec[:oracle]
|
17
|
+
ActiveRecord::Base.establish_connection(spec)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
print "Using native Oracle Enhanced\n"
|
2
|
+
require 'fileutils'
|
3
|
+
require 'logger'
|
4
|
+
require 'adapter_helper/oracle_enhanced'
|
5
|
+
require 'active_record'
|
6
|
+
|
7
|
+
log_path = File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. .. log]))
|
8
|
+
FileUtils.mkdir_p log_path
|
9
|
+
ActiveRecord::Base.logger = Logger.new("#{log_path}/debug.log")
|
10
|
+
ActiveRecord::Base.logger.level = Logger::DEBUG
|
11
|
+
|
12
|
+
def connection_string
|
13
|
+
"#{connection_SPEC['username']}/#{connection_SPEC['password']}@#{connection_SPEC['host']}"
|
14
|
+
end
|
15
|
+
|
16
|
+
# Adapter config setup in locals/database_connections.rb
|
17
|
+
spec = CompositePrimaryKeys::ConnectionSpec[:oracle]
|
18
|
+
ActiveRecord::Base.establish_connection(spec)
|
19
|
+
|
20
|
+
# Change default options for Oracle Enhanced adapter
|
21
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
|
22
|
+
# Change NLS_DATE_FORMAT to non-default format to verify that all tests should pass
|
23
|
+
ActiveRecord::Base.connection.execute %q{alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS'}
|
@@ -1,9 +1,17 @@
|
|
1
1
|
print "Using native Postgresql\n"
|
2
|
+
|
2
3
|
require 'logger'
|
3
|
-
require '
|
4
|
+
require 'active_record'
|
5
|
+
require File.join(PROJECT_ROOT, 'test', 'connections', 'connection_spec')
|
6
|
+
require File.join(PROJECT_ROOT, 'lib', 'composite_primary_keys', 'connection_adapters', 'postgresql_adapter')
|
4
7
|
|
5
|
-
|
8
|
+
def connection_string
|
9
|
+
options = {}
|
10
|
+
options['U'] = SPEC['username'] if SPEC['username']
|
11
|
+
options['p'] = SPEC['password'] if SPEC['password']
|
12
|
+
options.map { |key, value| "-#{key} #{value}" }.join(" ")
|
13
|
+
end
|
6
14
|
|
7
|
-
|
8
|
-
|
9
|
-
ActiveRecord::Base.establish_connection(
|
15
|
+
ActiveRecord::Base.logger = Logger.new("debug.log")
|
16
|
+
SPEC = CompositePrimaryKeys::ConnectionSpec[:postgresql]
|
17
|
+
ActiveRecord::Base.establish_connection(SPEC)
|