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.
- checksums.yaml +5 -5
- data/.gitignore +1 -2
- data/.travis.yml +15 -416
- data/Gemfile +35 -37
- data/README.md +23 -118
- data/RUNNING_TESTS.md +31 -26
- data/Rakefile +2 -3
- data/activerecord-jdbc-adapter.gemspec +1 -2
- data/lib/arjdbc/abstract/connection_management.rb +21 -0
- data/lib/arjdbc/abstract/core.rb +62 -0
- data/lib/arjdbc/abstract/database_statements.rb +46 -0
- data/lib/arjdbc/abstract/statement_cache.rb +58 -0
- data/lib/arjdbc/abstract/transaction_support.rb +86 -0
- data/lib/arjdbc/derby/adapter.rb +6 -1
- data/lib/arjdbc/discover.rb +0 -7
- data/lib/arjdbc/firebird/adapter.rb +2 -2
- data/lib/arjdbc/jdbc/adapter.rb +10 -252
- data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
- data/lib/arjdbc/jdbc/connection.rb +6 -0
- data/lib/arjdbc/jdbc.rb +2 -2
- data/lib/arjdbc/mysql/adapter.rb +87 -944
- data/lib/arjdbc/mysql/connection_methods.rb +4 -2
- data/lib/arjdbc/postgresql/adapter.rb +288 -1023
- data/lib/arjdbc/postgresql/base/array_decoder.rb +26 -0
- data/lib/arjdbc/postgresql/base/array_encoder.rb +25 -0
- data/lib/arjdbc/postgresql/base/pgconn.rb +8 -5
- data/lib/arjdbc/postgresql/column.rb +10 -599
- data/lib/arjdbc/postgresql/connection_methods.rb +9 -0
- data/lib/arjdbc/postgresql/name.rb +24 -0
- data/lib/arjdbc/postgresql/oid_types.rb +25 -110
- data/lib/arjdbc/sqlite3/adapter.rb +171 -170
- data/lib/arjdbc/tasks/database_tasks.rb +1 -3
- data/lib/arjdbc/tasks/db2_database_tasks.rb +2 -2
- data/lib/arjdbc/version.rb +1 -1
- data/pom.xml +3 -3
- data/rakelib/02-test.rake +0 -12
- data/rakelib/compile.rake +1 -1
- data/rakelib/db.rake +7 -5
- data/rakelib/rails.rake +63 -64
- data/src/java/arjdbc/firebird/FirebirdRubyJdbcConnection.java +1 -17
- data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +518 -1260
- data/src/java/arjdbc/mysql/MySQLModule.java +3 -3
- data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +53 -134
- data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +214 -240
- data/src/java/arjdbc/sqlite3/SQLite3Module.java +0 -20
- data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +85 -10
- metadata +20 -34
- data/Appraisals +0 -41
- data/lib/active_record/connection_adapters/oracle_adapter.rb +0 -1
- data/lib/arjdbc/common_jdbc_methods.rb +0 -89
- data/lib/arjdbc/mysql/bulk_change_table.rb +0 -150
- data/lib/arjdbc/mysql/column.rb +0 -162
- data/lib/arjdbc/mysql/explain_support.rb +0 -82
- data/lib/arjdbc/mysql/schema_creation.rb +0 -58
- data/lib/arjdbc/oracle/adapter.rb +0 -952
- data/lib/arjdbc/oracle/column.rb +0 -126
- data/lib/arjdbc/oracle/connection_methods.rb +0 -21
- data/lib/arjdbc/oracle.rb +0 -4
- data/lib/arjdbc/postgresql/_bc_time_cast_patch.rb +0 -21
- data/lib/arjdbc/postgresql/base/oid.rb +0 -412
- data/lib/arjdbc/postgresql/base/schema_definitions.rb +0 -131
- data/lib/arjdbc/postgresql/explain_support.rb +0 -53
- data/lib/arjdbc/postgresql/oid/bytea.rb +0 -2
- data/lib/arjdbc/postgresql/schema_creation.rb +0 -60
- data/lib/arjdbc/tasks/oracle/enhanced_structure_dump.rb +0 -297
- data/lib/arjdbc/tasks/oracle_database_tasks.rb +0 -65
- data/src/java/arjdbc/oracle/OracleModule.java +0 -75
- data/src/java/arjdbc/oracle/OracleRubyJdbcConnection.java +0 -465
data/rakelib/rails.rake
CHANGED
@@ -1,77 +1,76 @@
|
|
1
|
-
|
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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
"
|
14
|
-
|
15
|
-
|
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
|
-
|
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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
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
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
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
|
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());
|