activerecord-jdbc-adapter 1.2.2.1 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. data/.gitignore +1 -2
  2. data/.travis.yml +18 -3
  3. data/Appraisals +16 -0
  4. data/Gemfile +10 -10
  5. data/Gemfile.lock +27 -17
  6. data/LICENSE.txt +20 -17
  7. data/README.rdoc +29 -14
  8. data/Rakefile +4 -4
  9. data/activerecord-jdbc-adapter.gemspec +2 -1
  10. data/gemfiles/rails23.gemfile +12 -0
  11. data/gemfiles/rails23.gemfile.lock +44 -0
  12. data/gemfiles/rails30.gemfile +11 -0
  13. data/gemfiles/rails30.gemfile.lock +39 -0
  14. data/gemfiles/rails31.gemfile +11 -0
  15. data/gemfiles/rails31.gemfile.lock +41 -0
  16. data/gemfiles/rails32.gemfile +11 -0
  17. data/gemfiles/rails32.gemfile.lock +41 -0
  18. data/lib/arel/visitors/sql_server.rb +7 -0
  19. data/lib/arjdbc/db2/adapter.rb +82 -32
  20. data/lib/arjdbc/derby.rb +0 -4
  21. data/lib/arjdbc/derby/adapter.rb +1 -1
  22. data/lib/arjdbc/derby/connection_methods.rb +3 -2
  23. data/lib/arjdbc/discover.rb +16 -1
  24. data/lib/arjdbc/firebird/adapter.rb +5 -1
  25. data/lib/arjdbc/h2.rb +0 -1
  26. data/lib/arjdbc/h2/connection_methods.rb +3 -1
  27. data/lib/arjdbc/hsqldb.rb +0 -1
  28. data/lib/arjdbc/hsqldb/adapter.rb +4 -3
  29. data/lib/arjdbc/hsqldb/connection_methods.rb +3 -3
  30. data/lib/arjdbc/informix/adapter.rb +5 -1
  31. data/lib/arjdbc/jdbc/adapter.rb +22 -24
  32. data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
  33. data/lib/arjdbc/jdbc/base_ext.rb +1 -1
  34. data/lib/arjdbc/jdbc/connection.rb +23 -29
  35. data/lib/arjdbc/jdbc/core_ext.rb +1 -1
  36. data/lib/arjdbc/jdbc/discover.rb +1 -1
  37. data/lib/arjdbc/jdbc/driver.rb +1 -1
  38. data/lib/arjdbc/jdbc/extension.rb +3 -3
  39. data/lib/arjdbc/jdbc/jdbc.rake +15 -5
  40. data/lib/arjdbc/mssql.rb +0 -1
  41. data/lib/arjdbc/mssql/adapter.rb +10 -4
  42. data/lib/arjdbc/mssql/connection_methods.rb +15 -15
  43. data/lib/arjdbc/mssql/limit_helpers.rb +24 -2
  44. data/lib/arjdbc/mssql/tsql_helper.rb +0 -8
  45. data/lib/arjdbc/mysql.rb +0 -1
  46. data/lib/arjdbc/mysql/adapter.rb +82 -0
  47. data/lib/arjdbc/mysql/connection_methods.rb +3 -4
  48. data/lib/arjdbc/oracle/adapter.rb +12 -2
  49. data/lib/arjdbc/postgresql.rb +0 -1
  50. data/lib/arjdbc/postgresql/adapter.rb +127 -27
  51. data/lib/arjdbc/postgresql/connection_methods.rb +3 -4
  52. data/lib/arjdbc/sqlite3.rb +0 -1
  53. data/lib/arjdbc/sqlite3/adapter.rb +13 -14
  54. data/lib/arjdbc/sqlite3/connection_methods.rb +3 -4
  55. data/lib/arjdbc/version.rb +1 -1
  56. data/rakelib/01-tomcat.rake +52 -0
  57. data/rakelib/02-test.rake +111 -0
  58. data/rakelib/db.rake +4 -3
  59. data/src/java/arjdbc/db2/DB2RubyJdbcConnection.java +7 -0
  60. data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +8 -3
  61. data/test/abstract_db_create.rb +5 -1
  62. data/test/activerecord/connection_adapters/type_conversion_test.rb +0 -1
  63. data/test/activerecord/jall.sh +0 -0
  64. data/test/activerecord/jtest.sh +0 -0
  65. data/test/db/db2.rb +2 -0
  66. data/test/db/derby.rb +3 -5
  67. data/test/db/h2.rb +3 -1
  68. data/test/db/hsqldb.rb +2 -0
  69. data/test/db/informix.rb +2 -0
  70. data/test/db/jdbc.rb +11 -10
  71. data/test/db/jdbc_derby.rb +14 -0
  72. data/test/db/jdbc_h2.rb +17 -0
  73. data/test/db/jdbc_mysql.rb +13 -0
  74. data/test/db/jdbc_postgres.rb +23 -0
  75. data/test/db/jndi_config.rb +28 -33
  76. data/test/db/jndi_pooled_config.rb +35 -0
  77. data/test/db/logger.rb +1 -1
  78. data/test/db/mssql.rb +2 -0
  79. data/test/db/mysql.rb +2 -7
  80. data/test/db/mysql_config.rb +7 -0
  81. data/test/db/oracle.rb +2 -0
  82. data/test/db/postgres.rb +9 -7
  83. data/test/db/postgres_config.rb +10 -0
  84. data/test/db/sqlite3.rb +2 -0
  85. data/test/db2_reset_column_information_test.rb +0 -2
  86. data/test/derby_migration_test.rb +0 -1
  87. data/test/derby_multibyte_test.rb +0 -1
  88. data/test/derby_reset_column_information_test.rb +0 -3
  89. data/test/derby_row_locking_test.rb +0 -3
  90. data/test/derby_simple_test.rb +0 -1
  91. data/test/generic_jdbc_connection_test.rb +72 -17
  92. data/test/h2_change_column_test.rb +0 -1
  93. data/test/h2_simple_test.rb +0 -1
  94. data/test/helper.rb +22 -91
  95. data/test/jdbc_common.rb +98 -3
  96. data/test/jndi_callbacks_test.rb +6 -5
  97. data/test/jndi_test.rb +40 -15
  98. data/test/models/custom_pk_name.rb +14 -0
  99. data/test/mssql_ignore_system_views_test.rb +7 -4
  100. data/test/mssql_limit_offset_test.rb +30 -0
  101. data/test/mssql_multibyte_test.rb +1 -2
  102. data/test/mssql_reset_column_information_test.rb +0 -2
  103. data/test/mssql_row_locking_sql_test.rb +0 -2
  104. data/test/mssql_row_locking_test.rb +0 -2
  105. data/test/mysql_reset_column_information_test.rb +0 -2
  106. data/test/mysql_simple_test.rb +3 -18
  107. data/test/oracle_limit_test.rb +23 -0
  108. data/test/oracle_reset_column_information_test.rb +0 -2
  109. data/test/postgres_db_create_test.rb +0 -1
  110. data/test/postgres_drop_db_test.rb +0 -1
  111. data/test/postgres_information_schema_leak_test.rb +0 -1
  112. data/test/postgres_native_type_mapping_test.rb +17 -14
  113. data/test/postgres_nonseq_pkey_test.rb +0 -1
  114. data/test/postgres_reserved_test.rb +1 -2
  115. data/test/postgres_reset_column_information_test.rb +0 -3
  116. data/test/postgres_schema_search_path_test.rb +0 -1
  117. data/test/postgres_simple_test.rb +40 -1
  118. data/test/postgres_table_alias_length_test.rb +0 -1
  119. data/test/postgres_type_conversion_test.rb +0 -1
  120. data/test/row_locking.rb +6 -2
  121. data/test/simple.rb +57 -20
  122. data/test/sqlite3_reset_column_information_test.rb +0 -2
  123. data/test/sqlite3_simple_test.rb +1 -16
  124. data/test/sybase_reset_column_information_test.rb +0 -2
  125. metadata +366 -343
  126. data/lib/arjdbc/jdbc/require_driver.rb +0 -16
@@ -1,4 +1,3 @@
1
1
  require 'arjdbc/jdbc'
2
- jdbc_require_driver 'jdbc/sqlite3'
3
2
  require 'arjdbc/sqlite3/connection_methods'
4
3
  require 'arjdbc/sqlite3/adapter'
@@ -119,8 +119,17 @@ module ::ArJdbc
119
119
  tp
120
120
  end
121
121
 
122
+ def quote(value, column = nil)
123
+ if value.kind_of?(String) && column && column.type == :binary && column.class.respond_to?(:string_to_binary)
124
+ s = column.class.string_to_binary(value).unpack("H*")[0]
125
+ "x'#{s}'"
126
+ else
127
+ super
128
+ end
129
+ end
130
+
122
131
  def quote_column_name(name) #:nodoc:
123
- %Q("#{name.to_s.gsub('"', '""')}")
132
+ %Q("#{name.to_s.gsub('"', '""')}") # "' kludge for emacs font-lock
124
133
  end
125
134
 
126
135
  def quote_string(str)
@@ -181,12 +190,7 @@ module ::ArJdbc
181
190
  end
182
191
  end
183
192
 
184
- def primary_key(table_name) #:nodoc:
185
- column = table_structure(table_name).find {|field| field['pk'].to_i == 1}
186
- column ? column['name'] : nil
187
- end
188
-
189
- def recreate_database(name)
193
+ def recreate_database(name, options = {})
190
194
  tables.each{ |table| drop_table(table) }
191
195
  end
192
196
 
@@ -341,19 +345,14 @@ module ActiveRecord::ConnectionAdapters
341
345
  end
342
346
 
343
347
  def self.string_to_binary(value)
344
- "\000b64" + [value].pack('m*').split("\n").join('')
348
+ value
345
349
  end
346
350
 
347
351
  def self.binary_to_string(value)
348
352
  if value.respond_to?(:force_encoding) && value.encoding != Encoding::ASCII_8BIT
349
353
  value = value.force_encoding(Encoding::ASCII_8BIT)
350
354
  end
351
-
352
- if value[0..3] == "\000b64"
353
- value[4..-1].unpack('m*').first
354
- else
355
- value
356
- end
355
+ value
357
356
  end
358
357
  end
359
358
 
@@ -5,17 +5,18 @@ $LOADED_FEATURES << "active_record/connection_adapters/sqlite3_adapter.rb"
5
5
  class ActiveRecord::Base
6
6
  class << self
7
7
  def sqlite3_connection(config)
8
- require "arjdbc/sqlite3"
8
+ require 'active_record/connection_adapters/jdbcsqlite3_adapter'
9
9
 
10
10
  parse_sqlite3_config!(config)
11
11
  database = config[:database]
12
12
  database = '' if database == ':memory:'
13
13
  config[:url] ||= "jdbc:sqlite:#{database}"
14
- config[:driver] ||= "org.sqlite.JDBC"
14
+ config[:driver] ||= defined?(::Jdbc::SQLite3.driver_name) ? ::Jdbc::SQLite3.driver_name : 'org.sqlite.JDBC'
15
15
  config[:adapter_class] = ActiveRecord::ConnectionAdapters::SQLite3Adapter
16
16
  config[:adapter_spec] = ::ArJdbc::SQLite3
17
17
  jdbc_connection(config)
18
18
  end
19
+ alias_method :jdbcsqlite3_connection, :sqlite3_connection
19
20
 
20
21
  def parse_sqlite3_config!(config)
21
22
  config[:database] ||= config[:dbfile]
@@ -29,7 +30,5 @@ class ActiveRecord::Base
29
30
  config[:database] = File.expand_path(config[:database], rails_root)
30
31
  end
31
32
  end
32
-
33
- alias_method :jdbcsqlite3_connection, :sqlite3_connection
34
33
  end
35
34
  end
@@ -1,6 +1,6 @@
1
1
  module ArJdbc
2
2
  module Version
3
- VERSION = "1.2.2.1"
3
+ VERSION = "1.2.5"
4
4
  end
5
5
  end
6
6
  # Compatibility with older versions of ar-jdbc for other extensions out there
@@ -0,0 +1,52 @@
1
+
2
+ namespace :'tomcat-jndi' do # contains a FS JNDI impl (for tests)
3
+
4
+ TOMCAT_MAVEN_REPO = 'http://repo2.maven.org/maven2/org/apache/tomcat'
5
+ TOMCAT_VERSION = '7.0.34'
6
+
7
+ DOWNLOAD_DIR = File.expand_path('../test/jars', File.dirname(__FILE__))
8
+
9
+ #tomcat_jar = "tomcat-embed-core.jar"
10
+ #tomcat_uri = "#{TOMCAT_MAVEN_REPO}/embed/tomcat-embed-core/#{TOMCAT_VERSION}/tomcat-embed-core-#{TOMCAT_VERSION}.jar"
11
+
12
+ catalina_jar = "tomcat-catalina.jar"
13
+ catalina_uri = "#{TOMCAT_MAVEN_REPO}/tomcat-catalina/#{TOMCAT_VERSION}/tomcat-catalina-#{TOMCAT_VERSION}.jar"
14
+
15
+ juli_jar = "tomcat-juli.jar"
16
+ juli_uri = "#{TOMCAT_MAVEN_REPO}/tomcat-juli/#{TOMCAT_VERSION}/tomcat-juli-#{TOMCAT_VERSION}.jar"
17
+
18
+ task :download do
19
+ require 'open-uri'; require 'tmpdir'
20
+
21
+ temp_dir = File.join(Dir.tmpdir, (Time.now.to_f * 1000).to_i.to_s)
22
+ FileUtils.mkdir temp_dir
23
+
24
+ downloads = Hash.new
25
+ downloads[juli_jar] = juli_uri
26
+ downloads[catalina_jar] = catalina_uri
27
+
28
+ Dir.chdir(temp_dir) do
29
+ FileUtils.mkdir DOWNLOAD_DIR unless File.exist?(DOWNLOAD_DIR)
30
+ downloads.each do |jar, uri|
31
+ puts "downloading #{uri}"
32
+ file = open(uri)
33
+ FileUtils.cp file.path, File.join(DOWNLOAD_DIR, jar)
34
+ end
35
+ end
36
+
37
+ FileUtils.rm_r temp_dir
38
+ end
39
+
40
+ task :check do
41
+ jar_path = File.join(DOWNLOAD_DIR, catalina_jar)
42
+ unless File.exist?(jar_path)
43
+ Rake::Task['tomcat-jndi:download'].invoke
44
+ end
45
+ end
46
+
47
+ task :clear do
48
+ jar_path = File.join(DOWNLOAD_DIR, catalina_jar)
49
+ rm jar_path if File.exist?(jar_path)
50
+ end
51
+
52
+ end
@@ -0,0 +1,111 @@
1
+ require File.expand_path '../../test/helper', __FILE__
2
+ if defined?(JRUBY_VERSION)
3
+ databases = [ :test_mysql, :test_sqlite3, :test_derby, :test_hsqldb, :test_h2 ]
4
+ databases << :test_postgres if PostgresHelper.have_postgres?(false)
5
+ databases << :test_jdbc ; databases << :test_jndi
6
+ task :test do
7
+ unless PostgresHelper.have_postgres?
8
+ warn "... won't run test_postgres tests"
9
+ end
10
+ databases.each { |task| Rake::Task[task.to_s].invoke }
11
+ end
12
+ else
13
+ task :test => [ :test_mysql ]
14
+ end
15
+
16
+ def set_compat_version(task)
17
+ task.ruby_opts << '-v' if RUBY_VERSION =~ /1\.8/
18
+ if defined?(JRUBY_VERSION)
19
+ task.ruby_opts << "--#{RUBY_VERSION[/^(\d+\.\d+)/, 1]}"
20
+ end
21
+ end
22
+
23
+ def all_appraisal_names
24
+ @appraisal_names ||= begin names = []; Appraisal::File.each { |file| names << file.name }; names end
25
+ end
26
+
27
+ def declare_test_task_for(adapter, options = {})
28
+ driver = options[:driver] || adapter
29
+ prereqs = options[:prereqs] || []
30
+ prereqs = [ prereqs ].flatten
31
+ task "test_#{adapter}_pre" do
32
+ puts "Specify AR version with 'rake appraisal:{version} test_#{adapter}' where version=(#{all_appraisal_names.join('|')})"
33
+ end
34
+ prereqs << "test_#{adapter}_pre"
35
+ test_task = lambda do |t|
36
+ task_name = t.name.keys.first
37
+ files = FileList["test/#{adapter}*test.rb"]
38
+ files.unshift "test/db/#{task_name.sub('test_','')}.rb"
39
+ if adapter == "derby"
40
+ files << 'test/activerecord/connection_adapters/type_conversion_test.rb'
41
+ end
42
+ t.test_files = files
43
+ t.libs = []
44
+ set_compat_version(t)
45
+ if defined?(JRUBY_VERSION)
46
+ t.ruby_opts << "-rjdbc/#{driver}"
47
+ t.libs << "lib" << "jdbc-#{driver}/lib"
48
+ t.libs.push *FileList["activerecord-jdbc#{adapter}*/lib"]
49
+ end
50
+ t.libs << "test"
51
+ t.verbose = true
52
+ end
53
+ Rake::TestTask.new("test_#{adapter}" => prereqs) { |t| test_task.call t }
54
+ Rake::TestTask.new("test_jdbc_#{adapter}" => prereqs) { |t| test_task.call t }
55
+ end
56
+
57
+ declare_test_task_for :derby
58
+ declare_test_task_for :h2
59
+ declare_test_task_for :hsqldb
60
+ declare_test_task_for :mssql, :driver => :jtds
61
+ declare_test_task_for :mysql, :prereqs => "db:mysql"
62
+ declare_test_task_for :postgres, :prereqs => "db:postgres"
63
+ declare_test_task_for :sqlite3
64
+
65
+ Rake::TestTask.new(:test_jdbc) do |t|
66
+ t.test_files = FileList['test/generic_jdbc_connection_test.rb']
67
+ t.libs << 'test' << 'jdbc-mysql/lib'
68
+ set_compat_version(t)
69
+ end
70
+
71
+ Rake::TestTask.new(:test_jndi) do |t|
72
+ Rake::Task['tomcat-jndi:check'].invoke
73
+ t.test_files = FileList['test/jndi_test.rb']
74
+ t.libs << 'test' << 'jdbc-derby/lib'
75
+ set_compat_version(t)
76
+ end
77
+
78
+ task :test_postgresql => [:test_postgres]
79
+ task :test_pgsql => [:test_postgres]
80
+
81
+ # Ensure driver for these DBs is on your classpath
82
+ %w(oracle db2 cachedb informix).each do |d|
83
+ Rake::TestTask.new("test_#{d}") do |t|
84
+ t.test_files = FileList["test/#{d}*_test.rb"]
85
+ t.libs = []
86
+ t.libs << 'lib' if defined?(JRUBY_VERSION)
87
+ t.libs << 'test'
88
+ set_compat_version(t)
89
+ end
90
+ end
91
+
92
+ # Tests for JDBC adapters that don't require a database.
93
+ Rake::TestTask.new(:test_jdbc_adapters) do | t |
94
+ t.test_files = FileList[ 'test/jdbc_adapter/jdbc_sybase_test.rb' ]
95
+ t.libs << 'test'
96
+ set_compat_version(t)
97
+ end
98
+
99
+ # Ensure that the jTDS driver is in your classpath before launching rake
100
+ Rake::TestTask.new(:test_sybase_jtds) do |t|
101
+ t.test_files = FileList['test/sybase_jtds_simple_test.rb']
102
+ t.libs << 'test'
103
+ set_compat_version(t)
104
+ end
105
+
106
+ # Ensure that the jConnect driver is in your classpath before launching rake
107
+ Rake::TestTask.new(:test_sybase_jconnect) do |t|
108
+ t.test_files = FileList['test/sybase_jconnect_simple_test.rb']
109
+ t.libs << 'test'
110
+ set_compat_version(t)
111
+ end
data/rakelib/db.rake CHANGED
@@ -1,7 +1,8 @@
1
+ require File.expand_path '../../test/helper', __FILE__
1
2
  namespace :db do
2
3
  desc "Creates the test database for MySQL."
3
4
  task :mysql do
4
- load 'test/db/mysql.rb' rescue nil
5
+ load 'test/db/mysql_config.rb' rescue nil
5
6
  t = Tempfile.new("mysql")
6
7
  t.puts <<-SQL
7
8
  DROP DATABASE IF EXISTS `#{MYSQL_CONFIG[:database]}`;
@@ -23,8 +24,8 @@ SQL
23
24
 
24
25
  desc "Creates the test database for PostgreSQL."
25
26
  task :postgres do
26
- fail unless have_postgres?
27
- load 'test/db/postgres.rb' rescue nil
27
+ fail unless PostgresHelper.have_postgres?
28
+ load 'test/db/postgres_config.rb' rescue nil
28
29
  t = Tempfile.new("psql")
29
30
  t.puts <<-SQL
30
31
  DROP DATABASE IF EXISTS #{POSTGRES_CONFIG[:database]};
@@ -37,10 +37,17 @@ import arjdbc.jdbc.RubyJdbcConnection;
37
37
  * @author mikestone
38
38
  */
39
39
  public class DB2RubyJdbcConnection extends RubyJdbcConnection {
40
+ private static final String[] TABLE_TYPES = new String[]{"TABLE", "VIEW", "SYNONYM", "MATERIALIZED QUERY TABLE", "ALIAS"};
41
+
40
42
  protected DB2RubyJdbcConnection(Ruby runtime, RubyClass metaClass) {
41
43
  super(runtime, metaClass);
42
44
  }
43
45
 
46
+ @Override
47
+ protected String[] getTableTypes() {
48
+ return TABLE_TYPES;
49
+ }
50
+
44
51
  @Override
45
52
  protected boolean databaseSupportsSchemas() {
46
53
  return true;
@@ -77,6 +77,7 @@ import org.jruby.util.ByteList;
77
77
  */
78
78
  public class RubyJdbcConnection extends RubyObject {
79
79
  private static final String[] TABLE_TYPE = new String[]{"TABLE"};
80
+ private static final String[] TABLE_TYPES = new String[]{"TABLE", "VIEW", "SYNONYM"};
80
81
 
81
82
  private static RubyObjectAdapter rubyApi;
82
83
 
@@ -104,6 +105,10 @@ public class RubyJdbcConnection extends RubyObject {
104
105
  return (RubyModule) runtime.getModule("ActiveRecord").getConstant("ConnectionAdapters");
105
106
  }
106
107
 
108
+ protected String[] getTableTypes() {
109
+ return TABLE_TYPES;
110
+ }
111
+
107
112
  @JRubyMethod(name = "begin")
108
113
  public IRubyObject begin(ThreadContext context) throws SQLException {
109
114
  final Ruby runtime = context.getRuntime();
@@ -126,9 +131,8 @@ public class RubyJdbcConnection extends RubyObject {
126
131
  String tableName = rubyApi.convertToRubyString(args[0]).getUnicodeValue();
127
132
  TableNameComponents components = extractTableNameComponents(c, defaultSchema, tableName);
128
133
 
129
- String[] tableTypes = new String[]{"TABLE","VIEW","SYNONYM"};
130
134
  RubyArray matchingTables = (RubyArray) tableLookupBlock(context.getRuntime(),
131
- components.catalog, components.schema, components.table, tableTypes, false).call(c);
135
+ components.catalog, components.schema, components.table, getTableTypes(), false).call(c);
132
136
  if (matchingTables.isEmpty()) {
133
137
  throw new SQLException("Table " + tableName + " does not exist");
134
138
  }
@@ -507,7 +511,7 @@ public class RubyJdbcConnection extends RubyObject {
507
511
  public static IRubyObject select_p(ThreadContext context, IRubyObject recv, IRubyObject _sql) {
508
512
  ByteList sql = rubyApi.convertToRubyString(_sql).getByteList();
509
513
 
510
- return context.getRuntime().newBoolean(startsWithNoCaseCmp(sql, SELECT) ||
514
+ return context.getRuntime().newBoolean(startsWithNoCaseCmp(sql, SELECT) || startsWithNoCaseCmp(sql, WITH) ||
511
515
  startsWithNoCaseCmp(sql, SHOW) || startsWithNoCaseCmp(sql, CALL));
512
516
  }
513
517
 
@@ -1246,6 +1250,7 @@ public class RubyJdbcConnection extends RubyObject {
1246
1250
  private static byte[] CALL = new byte[]{'c', 'a', 'l', 'l'};
1247
1251
  private static byte[] INSERT = new byte[] {'i', 'n', 's', 'e', 'r', 't'};
1248
1252
  private static byte[] SELECT = new byte[] {'s', 'e', 'l', 'e', 'c', 't'};
1253
+ private static byte[] WITH = new byte[] {'w', 'i', 't', 'h'};
1249
1254
  private static byte[] SHOW = new byte[] {'s', 'h', 'o', 'w'};
1250
1255
 
1251
1256
  private static boolean startsWithNoCaseCmp(ByteList bytelist, byte[] compare) {
@@ -82,8 +82,12 @@ module AbstractDbCreate
82
82
  end
83
83
  ar_version = $LOADED_FEATURES.grep(%r{active_record/version}).first
84
84
  ar_lib_path = $LOAD_PATH.detect {|p| p if File.exist?File.join(p, ar_version)}
85
+ # if the old style finder didn't work, assume we have the absolute path already
86
+ if ar_lib_path.nil? && File.exist?(ar_version)
87
+ ar_lib_path = ar_version.sub(%r{/active_record/version.*}, '')
88
+ end
85
89
  ar_lib_path = ar_lib_path.sub(%r{activerecord/lib}, 'railties/lib') # edge rails
86
- rails_lib_path = ar_lib_path.sub(/activerecord/, 'rails') # gem rails
90
+ rails_lib_path = ar_lib_path.sub(/activerecord-([\d\.]+)/, 'rails-\1') # gem rails
87
91
  load "#{rails_lib_path}/tasks/databases.rake"
88
92
  end
89
93
 
@@ -1,7 +1,6 @@
1
1
  require 'java'
2
2
  require 'models/data_types'
3
3
  require 'arjdbc'
4
- require 'db/derby'
5
4
  require 'test/unit'
6
5
 
7
6
  JInteger = java.lang.Integer
File without changes
File without changes
data/test/db/db2.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'jdbc_common'
2
+
1
3
  config = {
2
4
  # DB2 uses $USER if running locally, just add
3
5
  # yourself to your db2 groups in /etc/group
data/test/db/derby.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'jdbc_common'
2
+
1
3
  config = {
2
4
  :adapter => 'derby',
3
5
  :database => "derby-testdb"
@@ -5,8 +7,4 @@ config = {
5
7
 
6
8
  ActiveRecord::Base.establish_connection(config)
7
9
 
8
- at_exit {
9
- # Clean up derby files
10
- require 'fileutils'
11
- FileUtils.rm_rf('derby-testdb')
12
- }
10
+ at_exit { FileUtils.rm_rf('derby-testdb') }
data/test/db/h2.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'jdbc_common'
2
+
1
3
  config = {
2
4
  :adapter => 'h2',
3
5
  :database => 'test.db'
@@ -7,5 +9,5 @@ ActiveRecord::Base.establish_connection(config)
7
9
 
8
10
  at_exit {
9
11
  # Clean up hsqldb when done
10
- Dir['test.db*'].each {|f| File.delete(f)}
12
+ Dir['test.db*'].each {|f| FileUtils.rm_rf(f) }
11
13
  }
data/test/db/hsqldb.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'jdbc_common'
2
+
1
3
  config = {
2
4
  :adapter => 'hsqldb',
3
5
  :database => 'test.db'
data/test/db/informix.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'jdbc_common'
2
+
1
3
  config = {
2
4
  :username => 'blog',
3
5
  :password => 'blog',
data/test/db/jdbc.rb CHANGED
@@ -1,12 +1,13 @@
1
- require 'jdbc/mysql'
1
+ require 'jdbc_common'
2
+ require 'db/mysql_config'
2
3
 
3
- config = {
4
- # see db/mysql.rb
5
- :username => 'arjdbc',
6
- :password => 'arjdbc',
7
- :adapter => 'jdbc',
8
- :driver => 'com.mysql.jdbc.Driver',
9
- :url => 'jdbc:mysql://localhost:3306/arjdbc_test'
10
- }
4
+ require 'jdbc/mysql' # driver not loaded for plain JDBC
5
+ Jdbc::MySQL.load_driver
11
6
 
12
- ActiveRecord::Base.establish_connection(config)
7
+ ActiveRecord::Base.establish_connection({
8
+ :adapter => 'jdbc',
9
+ :driver => 'com.mysql.jdbc.Driver',
10
+ :url => "jdbc:mysql://#{MYSQL_CONFIG[:host]}/#{MYSQL_CONFIG[:database]}",
11
+ :username => MYSQL_CONFIG[:username],
12
+ :password => MYSQL_CONFIG[:password],
13
+ })