activerecord-jdbc-adapter 5.0.pre1 → 51.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -2
  3. data/.travis.yml +15 -416
  4. data/Gemfile +35 -37
  5. data/README.md +23 -118
  6. data/RUNNING_TESTS.md +31 -26
  7. data/Rakefile +2 -3
  8. data/activerecord-jdbc-adapter.gemspec +1 -2
  9. data/lib/arjdbc/abstract/connection_management.rb +21 -0
  10. data/lib/arjdbc/abstract/core.rb +62 -0
  11. data/lib/arjdbc/abstract/database_statements.rb +46 -0
  12. data/lib/arjdbc/abstract/statement_cache.rb +58 -0
  13. data/lib/arjdbc/abstract/transaction_support.rb +86 -0
  14. data/lib/arjdbc/derby/adapter.rb +6 -1
  15. data/lib/arjdbc/discover.rb +0 -7
  16. data/lib/arjdbc/firebird/adapter.rb +2 -2
  17. data/lib/arjdbc/jdbc/adapter.rb +10 -252
  18. data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
  19. data/lib/arjdbc/jdbc/connection.rb +6 -0
  20. data/lib/arjdbc/jdbc.rb +2 -2
  21. data/lib/arjdbc/mysql/adapter.rb +87 -944
  22. data/lib/arjdbc/mysql/connection_methods.rb +4 -2
  23. data/lib/arjdbc/postgresql/adapter.rb +288 -1023
  24. data/lib/arjdbc/postgresql/base/array_decoder.rb +26 -0
  25. data/lib/arjdbc/postgresql/base/array_encoder.rb +25 -0
  26. data/lib/arjdbc/postgresql/base/pgconn.rb +8 -5
  27. data/lib/arjdbc/postgresql/column.rb +10 -599
  28. data/lib/arjdbc/postgresql/connection_methods.rb +9 -0
  29. data/lib/arjdbc/postgresql/name.rb +24 -0
  30. data/lib/arjdbc/postgresql/oid_types.rb +25 -110
  31. data/lib/arjdbc/sqlite3/adapter.rb +171 -170
  32. data/lib/arjdbc/tasks/database_tasks.rb +1 -3
  33. data/lib/arjdbc/tasks/db2_database_tasks.rb +2 -2
  34. data/lib/arjdbc/version.rb +1 -1
  35. data/pom.xml +3 -3
  36. data/rakelib/02-test.rake +0 -12
  37. data/rakelib/compile.rake +1 -1
  38. data/rakelib/db.rake +7 -5
  39. data/rakelib/rails.rake +63 -64
  40. data/src/java/arjdbc/firebird/FirebirdRubyJdbcConnection.java +1 -17
  41. data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +518 -1260
  42. data/src/java/arjdbc/mysql/MySQLModule.java +3 -3
  43. data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +53 -134
  44. data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +214 -240
  45. data/src/java/arjdbc/sqlite3/SQLite3Module.java +0 -20
  46. data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +85 -10
  47. metadata +20 -34
  48. data/Appraisals +0 -41
  49. data/lib/active_record/connection_adapters/oracle_adapter.rb +0 -1
  50. data/lib/arjdbc/common_jdbc_methods.rb +0 -89
  51. data/lib/arjdbc/mysql/bulk_change_table.rb +0 -150
  52. data/lib/arjdbc/mysql/column.rb +0 -162
  53. data/lib/arjdbc/mysql/explain_support.rb +0 -82
  54. data/lib/arjdbc/mysql/schema_creation.rb +0 -58
  55. data/lib/arjdbc/oracle/adapter.rb +0 -952
  56. data/lib/arjdbc/oracle/column.rb +0 -126
  57. data/lib/arjdbc/oracle/connection_methods.rb +0 -21
  58. data/lib/arjdbc/oracle.rb +0 -4
  59. data/lib/arjdbc/postgresql/_bc_time_cast_patch.rb +0 -21
  60. data/lib/arjdbc/postgresql/base/oid.rb +0 -412
  61. data/lib/arjdbc/postgresql/base/schema_definitions.rb +0 -131
  62. data/lib/arjdbc/postgresql/explain_support.rb +0 -53
  63. data/lib/arjdbc/postgresql/oid/bytea.rb +0 -2
  64. data/lib/arjdbc/postgresql/schema_creation.rb +0 -60
  65. data/lib/arjdbc/tasks/oracle/enhanced_structure_dump.rb +0 -297
  66. data/lib/arjdbc/tasks/oracle_database_tasks.rb +0 -65
  67. data/src/java/arjdbc/oracle/OracleModule.java +0 -75
  68. data/src/java/arjdbc/oracle/OracleRubyJdbcConnection.java +0 -465
data/rakelib/rails.rake CHANGED
@@ -1,77 +1,76 @@
1
- namespace :rails do
2
-
3
- task :test do
4
- raise "need a DRIVER e.g. DRIVER=mysql" unless driver = ENV['DRIVER'] || ENV['ADAPTER']
5
- raise "need location of RAILS source code e.g. RAILS=../rails" unless rails_dir = ENV['RAILS']
6
- rails_dir = File.join(rails_dir, '..') if rails_dir =~ /activerecord$/
7
- activerecord_dir = File.join(rails_dir, 'activerecord') # rails/activerecord
1
+ DEFAULT_RAILS_DIR = File.join('..', 'rails')
2
+ DEFAULT_ADAPTERS = %w(MySQL SQLite3 Postgres)
8
3
 
9
- ar_jdbc_dir = File.expand_path('..', File.dirname(__FILE__))
10
-
11
- ruby_lib = [
12
- "#{ar_jdbc_dir}/lib",
13
- "#{ar_jdbc_dir}/test/rails",
14
- "#{ar_jdbc_dir}/jdbc-#{_driver(driver)}/lib",
15
- "#{ar_jdbc_dir}/activerecord-jdbc#{_adapter(driver)}-adapter/lib"
16
- ]
17
- ruby_lib << File.expand_path('activesupport/lib', rails_dir)
18
- ruby_lib << File.expand_path('activemodel/lib', rails_dir)
19
- ruby_lib << File.expand_path(File.join(activerecord_dir, 'lib'))
20
- requires = _requires(driver) || []
4
+ namespace :rails do
5
+ namespace :test do
6
+ task :all do
7
+ driver = ENV['DRIVER'] || ENV['ADAPTER']
8
+ raise "need a DRIVER (DRIVER=mysql)" unless driver
9
+ rails_dir = _rails_dir
10
+ ENV['ARCONFIG'] = File.join(_ar_jdbc_dir, 'test', 'rails', 'config.yml')
21
11
 
22
- Dir.chdir(activerecord_dir) do
23
- ruby = FileUtils::RUBY
24
- rubylib = ruby_lib.join(':') # i_lib = "-I#{rubylib}"
25
- r_requires = requires.map { |feat| "-r#{feat}" }.join(' ')
26
- sh "#{ruby} -S rake RUBYLIB=#{rubylib} RUBYOPT=\"#{r_requires}\" #{_target(driver)}"
12
+ sh "cd #{File.join(rails_dir, 'activerecord')}; #{FileUtils::RUBY} -S rake RUBYLIB=#{_ruby_lib(rails_dir, driver)} #{_target(driver)}"
27
13
  end
28
- end
29
-
30
- %w(MySQL SQLite3 Postgres).each do |adapter|
31
- desc "Run Rails' ActiveRecord tests with #{adapter} (JDBC)"
32
- task "test_#{adapter.downcase}" do
33
- ENV['ADAPTER'] = adapter; Rake::Task['rails:test'].invoke
14
+
15
+ DEFAULT_ADAPTERS.each do |adapter|
16
+ desc "Run Rails ActiveRecord tests with #{adapter} (JDBC)"
17
+ task adapter.downcase do
18
+ ENV['ADAPTER'] = adapter
19
+ Rake::Task['rails:test:all'].invoke
20
+ end
21
+
22
+ namespace adapter.downcase do
23
+ desc "Runs Rails ActiveRecord base_test.rb with #{adapter}"
24
+ task "base_test" do
25
+ ENV['TEST'] ||= "test/cases/base_test.rb"
26
+ ENV['ADAPTER'] = adapter
27
+ Rake::Task['rails:test:all'].invoke
28
+ end
29
+ end
34
30
  end
35
- end
36
-
37
- private
38
-
39
- def _adapter(name)
40
- case name
41
- when /postgres/i
42
- 'postgresql'
43
- else
44
- name.downcase
31
+
32
+ private
33
+
34
+ def _ar_jdbc_dir
35
+ @ar_jdbc_dir ||= File.expand_path('..', File.dirname(__FILE__))
45
36
  end
46
- end
47
37
 
48
- def _driver(name)
49
- case name
50
- when /postgres/i
51
- 'postgres'
52
- else
53
- name.downcase
38
+ def _rails_dir
39
+ rails_dir = ENV['RAILS'] || DEFAULT_RAILS_DIR
40
+ unless File.directory? rails_dir
41
+ raise "can't find RAILS source '#{rails_dir}' (maybe set ENV['RAILS'])"
42
+ end
43
+ rails_dir = File.join(rails_dir, '..') if rails_dir =~ /activerecord$/
44
+ rails_dir
54
45
  end
55
- end
56
46
 
57
- def _target(name)
58
- case name
59
- when /postgres/i
60
- 'test_jdbcpostgresql'
61
- else
62
- "test_jdbc#{name.downcase}"
47
+ def _ruby_lib(rails_dir, driver)
48
+ ar_jdbc_dir = _ar_jdbc_dir
49
+
50
+ if driver =~ /postgres/i
51
+ adapter, driver = 'postgresql', 'postgres'
52
+ else
53
+ adapter = driver.downcase
54
+ driver = adapter
55
+ end
56
+
57
+ [File.join(ar_jdbc_dir, 'lib'),
58
+ File.join(ar_jdbc_dir, 'test', 'rails'),
59
+ File.join(ar_jdbc_dir, "jdbc-#{driver}", 'lib'),
60
+ File.join(ar_jdbc_dir, "activerecord-jdbc#{adapter}-adapter", 'lib'),
61
+ File.expand_path('activesupport/lib', rails_dir),
62
+ File.expand_path('activemodel/lib', rails_dir),
63
+ File.expand_path('activerecord/lib', rails_dir)
64
+ ].join(':')
63
65
  end
64
- end
65
66
 
66
- def _requires(name)
67
- requires = []
68
- requires << 'ubygems'
69
- requires << 'active_support/json' # avoid uninitialized constant BasicsTest::JSON
70
- case name
71
- when /mysql/i
72
- requires << 'mysql' # -rmysql - so Rails tests do not complain about Mysql
67
+ def _target(name)
68
+ case name
69
+ when /postgres/i
70
+ 'test_postgresql'
71
+ else
72
+ "test_jdbc#{name.downcase}"
73
+ end
73
74
  end
74
- requires
75
75
  end
76
-
77
76
  end
@@ -70,27 +70,11 @@ public class FirebirdRubyJdbcConnection extends RubyJdbcConnection {
70
70
  return RubyString.newUnicodeString(runtime, value);
71
71
  }
72
72
 
73
- @Override // booleans are emulated can not setNull(index, Types.BOOLEAN)
74
- protected void setBooleanParameter(final ThreadContext context,
75
- final Connection connection, final PreparedStatement statement,
76
- final int index, final Object value,
77
- final IRubyObject column, final int type) throws SQLException {
78
- if ( value instanceof IRubyObject ) {
79
- setBooleanParameter(context, connection, statement, index, (IRubyObject) value, column, type);
80
- }
81
- else {
82
- if ( value == null ) statement.setNull(index, Types.CHAR);
83
- else {
84
- statement.setBoolean(index, ((Boolean) value).booleanValue());
85
- }
86
- }
87
- }
88
-
89
73
  @Override // booleans are emulated can not setNull(index, Types.BOOLEAN)
90
74
  protected void setBooleanParameter(final ThreadContext context,
91
75
  final Connection connection, final PreparedStatement statement,
92
76
  final int index, final IRubyObject value,
93
- final IRubyObject column, final int type) throws SQLException {
77
+ final IRubyObject attribute, final int type) throws SQLException {
94
78
  if ( value.isNil() ) statement.setNull(index, Types.CHAR);
95
79
  else {
96
80
  statement.setBoolean(index, value.isTrue());