mingusbabcock-composite_primary_keys 2.2.2 → 2.2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/History.txt +156 -0
  2. data/Manifest.txt +122 -0
  3. data/README.txt +41 -0
  4. data/README_DB2.txt +33 -0
  5. data/Rakefile +65 -0
  6. data/init.rb +2 -0
  7. data/install.rb +30 -0
  8. data/lib/adapter_helper/base.rb +63 -0
  9. data/lib/adapter_helper/mysql.rb +13 -0
  10. data/lib/adapter_helper/oracle.rb +12 -0
  11. data/lib/adapter_helper/postgresql.rb +13 -0
  12. data/lib/adapter_helper/sqlite3.rb +13 -0
  13. data/lib/composite_primary_keys.rb +56 -0
  14. data/lib/composite_primary_keys/association_preload.rb +253 -0
  15. data/lib/composite_primary_keys/associations.rb +428 -0
  16. data/lib/composite_primary_keys/attribute_methods.rb +84 -0
  17. data/lib/composite_primary_keys/base.rb +341 -0
  18. data/lib/composite_primary_keys/calculations.rb +69 -0
  19. data/lib/composite_primary_keys/composite_arrays.rb +30 -0
  20. data/lib/composite_primary_keys/connection_adapters/ibm_db_adapter.rb +21 -0
  21. data/lib/composite_primary_keys/connection_adapters/oracle_adapter.rb +15 -0
  22. data/lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb +53 -0
  23. data/lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb +15 -0
  24. data/lib/composite_primary_keys/fixtures.rb +8 -0
  25. data/lib/composite_primary_keys/migration.rb +20 -0
  26. data/lib/composite_primary_keys/reflection.rb +19 -0
  27. data/lib/composite_primary_keys/version.rb +8 -0
  28. data/loader.rb +24 -0
  29. data/local/database_connections.rb.sample +10 -0
  30. data/local/paths.rb.sample +2 -0
  31. data/local/tasks.rb.sample +2 -0
  32. data/scripts/console.rb +48 -0
  33. data/scripts/txt2html +67 -0
  34. data/scripts/txt2js +59 -0
  35. data/tasks/activerecord_selection.rake +43 -0
  36. data/tasks/databases.rake +12 -0
  37. data/tasks/databases/mysql.rake +30 -0
  38. data/tasks/databases/oracle.rake +25 -0
  39. data/tasks/databases/postgresql.rake +26 -0
  40. data/tasks/databases/sqlite3.rake +28 -0
  41. data/tasks/deployment.rake +22 -0
  42. data/tasks/local_setup.rake +13 -0
  43. data/tasks/website.rake +18 -0
  44. data/test/README_tests.txt +67 -0
  45. data/test/abstract_unit.rb +94 -0
  46. data/test/connections/native_ibm_db/connection.rb +23 -0
  47. data/test/connections/native_mysql/connection.rb +13 -0
  48. data/test/connections/native_oracle/connection.rb +14 -0
  49. data/test/connections/native_postgresql/connection.rb +9 -0
  50. data/test/connections/native_sqlite/connection.rb +9 -0
  51. data/test/fixtures/article.rb +5 -0
  52. data/test/fixtures/articles.yml +6 -0
  53. data/test/fixtures/comment.rb +6 -0
  54. data/test/fixtures/comments.yml +16 -0
  55. data/test/fixtures/db_definitions/db2-create-tables.sql +113 -0
  56. data/test/fixtures/db_definitions/db2-drop-tables.sql +16 -0
  57. data/test/fixtures/db_definitions/mysql.sql +174 -0
  58. data/test/fixtures/db_definitions/oracle.drop.sql +39 -0
  59. data/test/fixtures/db_definitions/oracle.sql +188 -0
  60. data/test/fixtures/db_definitions/postgresql.sql +199 -0
  61. data/test/fixtures/db_definitions/sqlite.sql +160 -0
  62. data/test/fixtures/department.rb +5 -0
  63. data/test/fixtures/departments.yml +3 -0
  64. data/test/fixtures/employee.rb +4 -0
  65. data/test/fixtures/employees.yml +9 -0
  66. data/test/fixtures/group.rb +3 -0
  67. data/test/fixtures/groups.yml +3 -0
  68. data/test/fixtures/hack.rb +6 -0
  69. data/test/fixtures/hacks.yml +2 -0
  70. data/test/fixtures/membership.rb +7 -0
  71. data/test/fixtures/membership_status.rb +3 -0
  72. data/test/fixtures/membership_statuses.yml +10 -0
  73. data/test/fixtures/memberships.yml +6 -0
  74. data/test/fixtures/product.rb +7 -0
  75. data/test/fixtures/product_tariff.rb +5 -0
  76. data/test/fixtures/product_tariffs.yml +12 -0
  77. data/test/fixtures/products.yml +6 -0
  78. data/test/fixtures/reading.rb +4 -0
  79. data/test/fixtures/readings.yml +10 -0
  80. data/test/fixtures/reference_code.rb +7 -0
  81. data/test/fixtures/reference_codes.yml +28 -0
  82. data/test/fixtures/reference_type.rb +7 -0
  83. data/test/fixtures/reference_types.yml +9 -0
  84. data/test/fixtures/street.rb +3 -0
  85. data/test/fixtures/streets.yml +15 -0
  86. data/test/fixtures/suburb.rb +6 -0
  87. data/test/fixtures/suburbs.yml +9 -0
  88. data/test/fixtures/tariff.rb +6 -0
  89. data/test/fixtures/tariffs.yml +13 -0
  90. data/test/fixtures/user.rb +10 -0
  91. data/test/fixtures/users.yml +6 -0
  92. data/test/hash_tricks.rb +34 -0
  93. data/test/plugins/pagination.rb +405 -0
  94. data/test/plugins/pagination_helper.rb +135 -0
  95. data/test/test_associations.rb +160 -0
  96. data/test/test_attribute_methods.rb +22 -0
  97. data/test/test_attributes.rb +84 -0
  98. data/test/test_clone.rb +34 -0
  99. data/test/test_composite_arrays.rb +51 -0
  100. data/test/test_create.rb +68 -0
  101. data/test/test_delete.rb +96 -0
  102. data/test/test_dummy.rb +28 -0
  103. data/test/test_exists.rb +29 -0
  104. data/test/test_find.rb +73 -0
  105. data/test/test_ids.rb +97 -0
  106. data/test/test_miscellaneous.rb +39 -0
  107. data/test/test_pagination.rb +38 -0
  108. data/test/test_polymorphic.rb +31 -0
  109. data/test/test_santiago.rb +27 -0
  110. data/test/test_tutorial_examle.rb +26 -0
  111. data/test/test_update.rb +40 -0
  112. data/website/index.html +199 -0
  113. data/website/index.txt +159 -0
  114. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  115. data/website/stylesheets/screen.css +126 -0
  116. data/website/template.js +3 -0
  117. data/website/template.rhtml +53 -0
  118. data/website/version-raw.js +3 -0
  119. data/website/version-raw.txt +2 -0
  120. data/website/version.js +4 -0
  121. data/website/version.txt +3 -0
  122. metadata +180 -18
@@ -0,0 +1,12 @@
1
+ require 'active_record'
2
+
3
+ # UNTESTED - firebird sqlserver sqlserver_odbc db2 sybase openbase
4
+ for adapter in %w( mysql sqlite oracle oracle_enhanced postgresql ibm_db )
5
+ Rake::TestTask.new("test_#{adapter}") { |t|
6
+ t.libs << "test" << "test/connections/native_#{adapter}"
7
+ t.pattern = "test/test_*.rb"
8
+ t.verbose = true
9
+ }
10
+ end
11
+
12
+ SCHEMA_PATH = File.join(PROJECT_ROOT, *%w(test fixtures db_definitions))
@@ -0,0 +1,30 @@
1
+ namespace :mysql do
2
+ desc 'Build the MySQL test databases'
3
+ task :build_databases => :load_connection do
4
+ puts File.join(SCHEMA_PATH, 'mysql.sql')
5
+ options_str = ENV['cpk_adapter_options_str']
6
+ # creates something like "-u#{username} -p#{password} -S#{socket}"
7
+ sh %{ mysqladmin #{options_str} create "#{GEM_NAME}_unittest" }
8
+ sh %{ mysql #{options_str} "#{GEM_NAME}_unittest" < #{File.join(SCHEMA_PATH, 'mysql.sql')} }
9
+ end
10
+
11
+ desc 'Drop the MySQL test databases'
12
+ task :drop_databases => :load_connection do
13
+ options_str = ENV['cpk_adapter_options_str']
14
+ sh %{ mysqladmin #{options_str} -f drop "#{GEM_NAME}_unittest" }
15
+ end
16
+
17
+ desc 'Rebuild the MySQL test databases'
18
+ task :rebuild_databases => [:drop_databases, :build_databases]
19
+
20
+ task :load_connection do
21
+ require File.join(PROJECT_ROOT, %w[lib adapter_helper mysql])
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
29
+ end
30
+ end
@@ -0,0 +1,25 @@
1
+ namespace :oracle do
2
+ desc 'Build the Oracle test databases'
3
+ task :build_databases => :load_connection do
4
+ puts File.join(SCHEMA_PATH, 'oracle.sql')
5
+ options_str = ENV['cpk_adapter_options_str']
6
+ sh %( sqlplus #{options_str} < #{File.join(SCHEMA_PATH, 'oracle.sql')} )
7
+ end
8
+
9
+ desc 'Drop the Oracle test databases'
10
+ task :drop_databases => :load_connection do
11
+ puts File.join(SCHEMA_PATH, 'oracle.drop.sql')
12
+ options_str = ENV['cpk_adapter_options_str']
13
+ sh %( sqlplus #{options_str} < #{File.join(SCHEMA_PATH, 'oracle.drop.sql')} )
14
+ end
15
+
16
+ desc 'Rebuild the Oracle test databases'
17
+ task :rebuild_databases => [:drop_databases, :build_databases]
18
+
19
+ task :load_connection do
20
+ require File.join(PROJECT_ROOT, %w[lib adapter_helper oracle])
21
+ spec = AdapterHelper::Oracle.load_connection_from_env
22
+ ENV['cpk_adapter_options_str'] = "#{spec[:username]}/#{spec[:password]}@#{spec[:host]}"
23
+ end
24
+
25
+ end
@@ -0,0 +1,26 @@
1
+ namespace :postgresql do
2
+ desc 'Build the PostgreSQL test databases'
3
+ task :build_databases => :load_connection do
4
+ sh %{ createdb "#{GEM_NAME}_unittest" }
5
+ sh %{ psql "#{GEM_NAME}_unittest" -f #{File.join(SCHEMA_PATH, 'postgresql.sql')} }
6
+ end
7
+
8
+ desc 'Drop the PostgreSQL test databases'
9
+ task :drop_databases => :load_connection do
10
+ sh %{ dropdb "#{GEM_NAME}_unittest" }
11
+ end
12
+
13
+ desc 'Rebuild the PostgreSQL test databases'
14
+ task :rebuild_databases => [:drop_databases, :build_databases]
15
+
16
+ task :load_connection do
17
+ require File.join(PROJECT_ROOT, %w[lib adapter_helper postgresql])
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
24
+ end
25
+ end
26
+
@@ -0,0 +1,28 @@
1
+ namespace :sqlite3 do
2
+ desc 'Build the sqlite test databases'
3
+ task :build_databases => :load_connection do
4
+ file = File.join(SCHEMA_PATH, 'sqlite.sql')
5
+ dbfile = File.join(PROJECT_ROOT, ENV['cpk_adapter_options_str'])
6
+ cmd = "mkdir -p #{File.dirname(dbfile)}"
7
+ puts cmd
8
+ sh %{ #{cmd} }
9
+ cmd = "sqlite3 #{dbfile} < #{file}"
10
+ puts cmd
11
+ sh %{ #{cmd} }
12
+ end
13
+
14
+ desc 'Drop the sqlite test databases'
15
+ task :drop_databases => :load_connection do
16
+ dbfile = ENV['cpk_adapter_options_str']
17
+ sh %{ rm -f #{dbfile} }
18
+ end
19
+
20
+ desc 'Rebuild the sqlite test databases'
21
+ task :rebuild_databases => [:drop_databases, :build_databases]
22
+
23
+ task :load_connection do
24
+ require File.join(PROJECT_ROOT, %w[lib adapter_helper sqlite3])
25
+ spec = AdapterHelper::Sqlite3.load_connection_from_env
26
+ ENV['cpk_adapter_options_str'] = spec[:dbfile]
27
+ end
28
+ end
@@ -0,0 +1,22 @@
1
+ desc 'Release the website and new gem version'
2
+ task :deploy => [:check_version, :website, :release] do
3
+ puts "Remember to create SVN tag:"
4
+ puts "svn copy svn+ssh://#{RUBYFORGE_USERNAME}@rubyforge.org/var/svn/#{PATH}/trunk " +
5
+ "svn+ssh://#{RUBYFORGE_USERNAME}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
6
+ puts "Suggested comment:"
7
+ puts "Tagging release #{CHANGES}"
8
+ end
9
+
10
+ desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
11
+ task :local_deploy => [:website_generate, :install_gem]
12
+
13
+ task :check_version do
14
+ unless ENV['VERSION']
15
+ puts 'Must pass a VERSION=x.y.z release version'
16
+ exit
17
+ end
18
+ unless ENV['VERSION'] == VERS
19
+ puts "Please update your version.rb to match the release version, currently #{VERS}"
20
+ exit
21
+ end
22
+ end
@@ -0,0 +1,13 @@
1
+ namespace :local do
2
+ desc 'Copies over the same local files ready for editing'
3
+ task :setup do
4
+ sample_files = Dir[File.join(PROJECT_ROOT, "local/*.rb.sample")]
5
+ sample_files.each do |sample_file|
6
+ file = sample_file.sub(".sample","")
7
+ unless File.exists?(file)
8
+ puts "Copying #{sample_file} -> #{file}"
9
+ sh %{ cp #{sample_file} #{file} }
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,18 @@
1
+ desc 'Generate website files'
2
+ task :website_generate do
3
+ sh %{ ruby scripts/txt2html website/index.txt > website/index.html }
4
+ sh %{ ruby scripts/txt2js website/version.txt > website/version.js }
5
+ sh %{ ruby scripts/txt2js website/version-raw.txt > website/version-raw.js }
6
+ end
7
+
8
+ desc 'Upload website files to rubyforge'
9
+ task :website_upload do
10
+ config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
11
+ host = "#{config["username"]}@rubyforge.org"
12
+ remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/"
13
+ local_dir = 'website'
14
+ sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
15
+ end
16
+
17
+ desc 'Generate and upload website files'
18
+ task :website => [:website_generate, :website_upload, :publish_docs]
@@ -0,0 +1,67 @@
1
+ = Composite Primary Keys - Testing Readme
2
+
3
+ == Testing an adapter
4
+
5
+ There are tests available for the following adapters:
6
+
7
+ * ibmdb
8
+ * mysql
9
+ * oracle
10
+ * postgresql
11
+ * sqlite
12
+
13
+ To run the tests for on of the adapters, follow these steps (using mysql in the example):
14
+
15
+ * rake -T | grep mysql
16
+
17
+ rake mysql:build_databases # Build the MySQL test databases
18
+ rake mysql:drop_databases # Drop the MySQL test databases
19
+ rake mysql:rebuild_databases # Rebuild the MySQL test databases
20
+ rake test_mysql # Run tests for test_mysql
21
+
22
+ * rake mysql:build_databases
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
+
@@ -0,0 +1,94 @@
1
+ $:.unshift(ENV['AR_LOAD_PATH']) if ENV['AR_LOAD_PATH']
2
+
3
+ require 'test/unit'
4
+ require 'hash_tricks'
5
+ require 'rubygems'
6
+ require 'active_record'
7
+ require 'active_record/fixtures'
8
+ begin
9
+ require 'connection'
10
+ rescue MissingSourceFile => e
11
+ adapter = 'postgresql' #'sqlite'
12
+ require "#{File.dirname(__FILE__)}/connections/native_#{adapter}/connection"
13
+ end
14
+ require 'composite_primary_keys'
15
+
16
+ QUOTED_TYPE = ActiveRecord::Base.connection.quote_column_name('type') unless Object.const_defined?(:QUOTED_TYPE)
17
+
18
+ class Test::Unit::TestCase #:nodoc:
19
+ self.fixture_path = File.dirname(__FILE__) + "/fixtures/"
20
+ self.use_instantiated_fixtures = false
21
+ self.use_transactional_fixtures = true
22
+
23
+ def assert_date_from_db(expected, actual, message = nil)
24
+ # SQL Server doesn't have a separate column type just for dates,
25
+ # so the time is in the string and incorrectly formatted
26
+ if current_adapter?(:SQLServerAdapter)
27
+ assert_equal expected.strftime("%Y/%m/%d 00:00:00"), actual.strftime("%Y/%m/%d 00:00:00")
28
+ elsif current_adapter?(:SybaseAdapter)
29
+ assert_equal expected.to_s, actual.to_date.to_s, message
30
+ else
31
+ assert_equal expected.to_s, actual.to_s, message
32
+ end
33
+ end
34
+
35
+ def assert_queries(num = 1)
36
+ ActiveRecord::Base.connection.class.class_eval do
37
+ self.query_count = 0
38
+ alias_method :execute, :execute_with_query_counting
39
+ end
40
+ yield
41
+ ensure
42
+ ActiveRecord::Base.connection.class.class_eval do
43
+ alias_method :execute, :execute_without_query_counting
44
+ end
45
+ assert_equal num, ActiveRecord::Base.connection.query_count, "#{ActiveRecord::Base.connection.query_count} instead of #{num} queries were executed."
46
+ end
47
+
48
+ def assert_no_queries(&block)
49
+ assert_queries(0, &block)
50
+ end
51
+
52
+ cattr_accessor :classes
53
+ protected
54
+
55
+ def testing_with(&block)
56
+ classes.keys.each do |@key_test|
57
+ @klass_info = classes[@key_test]
58
+ @klass, @primary_keys = @klass_info[:class], @klass_info[:primary_keys]
59
+ order = @klass.primary_key.is_a?(String) ? @klass.primary_key : @klass.primary_key.join(',')
60
+ @first = @klass.find(:first, :order => order)
61
+ yield
62
+ end
63
+ end
64
+
65
+ def first_id
66
+ ids = (1..@primary_keys.length).map {|num| 1}
67
+ composite? ? ids.to_composite_ids : ids.first
68
+ end
69
+
70
+ def first_id_str
71
+ composite? ? first_id.join(CompositePrimaryKeys::ID_SEP) : first_id.to_s
72
+ end
73
+
74
+ def composite?
75
+ @key_test != :single
76
+ end
77
+ end
78
+
79
+ def current_adapter?(type)
80
+ ActiveRecord::ConnectionAdapters.const_defined?(type) &&
81
+ ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters.const_get(type))
82
+ end
83
+
84
+ ActiveRecord::Base.connection.class.class_eval do
85
+ cattr_accessor :query_count
86
+ alias_method :execute_without_query_counting, :execute
87
+ def execute_with_query_counting(sql, name = nil)
88
+ self.query_count += 1
89
+ execute_without_query_counting(sql, name)
90
+ end
91
+ end
92
+
93
+ #ActiveRecord::Base.logger = Logger.new(STDOUT)
94
+ #ActiveRecord::Base.colorize_logging = false
@@ -0,0 +1,23 @@
1
+ print "Using IBM2 \n"
2
+ require 'logger'
3
+
4
+ gem 'ibm_db'
5
+ require 'IBM_DB'
6
+
7
+ RAILS_CONNECTION_ADAPTERS = %w( mysql postgresql sqlite firebird sqlserver db2 oracle sybase openbase frontbase ibm_db )
8
+
9
+
10
+ ActiveRecord::Base.logger = Logger.new("debug.log")
11
+
12
+ db1 = 'composite_primary_keys_unittest'
13
+
14
+ connection_options = {
15
+ :adapter => "ibm_db",
16
+ :database => "ocdpdev",
17
+ :username => "db2inst1",
18
+ :password => "password",
19
+ :host => '192.168.2.21'
20
+ }
21
+
22
+ ActiveRecord::Base.configurations = { db1 => connection_options }
23
+ ActiveRecord::Base.establish_connection(connection_options)
@@ -0,0 +1,13 @@
1
+ print "Using native MySQL\n"
2
+ require 'fileutils'
3
+ require 'logger'
4
+ require 'adapter_helper/mysql'
5
+
6
+ log_path = File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. .. log]))
7
+ FileUtils.mkdir_p log_path
8
+ puts "Logging to #{log_path}/debug.log"
9
+ ActiveRecord::Base.logger = Logger.new("#{log_path}/debug.log")
10
+
11
+ # Adapter config setup in locals/database_connections.rb
12
+ connection_options = AdapterHelper::MySQL.load_connection_from_env
13
+ ActiveRecord::Base.establish_connection(connection_options)
@@ -0,0 +1,14 @@
1
+ print "Using native Oracle\n"
2
+ require 'fileutils'
3
+ require 'logger'
4
+ require 'adapter_helper/oracle'
5
+
6
+ log_path = File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. .. log]))
7
+ FileUtils.mkdir_p log_path
8
+ puts "Logging to #{log_path}/debug.log"
9
+ ActiveRecord::Base.logger = Logger.new("#{log_path}/debug.log")
10
+
11
+ # Adapter config setup in locals/database_connections.rb
12
+ connection_options = AdapterHelper::Oracle.load_connection_from_env
13
+ puts connection_options.inspect
14
+ ActiveRecord::Base.establish_connection(connection_options)
@@ -0,0 +1,9 @@
1
+ print "Using native Postgresql\n"
2
+ require 'logger'
3
+ require 'adapter_helper/postgresql'
4
+
5
+ ActiveRecord::Base.logger = Logger.new("debug.log")
6
+
7
+ # Adapter config setup in locals/database_connections.rb
8
+ connection_options = AdapterHelper::Postgresql.load_connection_from_env
9
+ ActiveRecord::Base.establish_connection(connection_options)
@@ -0,0 +1,9 @@
1
+ print "Using native Sqlite3\n"
2
+ require 'logger'
3
+ require 'adapter_helper/sqlite3'
4
+
5
+ ActiveRecord::Base.logger = Logger.new("debug.log")
6
+
7
+ # Adapter config setup in locals/database_connections.rb
8
+ connection_options = AdapterHelper::Sqlite3.load_connection_from_env
9
+ ActiveRecord::Base.establish_connection(connection_options)
@@ -0,0 +1,5 @@
1
+ class Article < ActiveRecord::Base
2
+ has_many :readings
3
+ has_many :users, :through => :readings
4
+ end
5
+
@@ -0,0 +1,6 @@
1
+ first:
2
+ id: 1
3
+ name: Article One
4
+ second:
5
+ id: 2
6
+ name: Article Two