activerecord-jdbc-adapter 1.0.3-java → 50.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +33 -0
- data/.travis.yml +79 -0
- data/.yardopts +4 -0
- data/CONTRIBUTING.md +50 -0
- data/Gemfile +91 -0
- data/History.md +1191 -0
- data/LICENSE.txt +22 -17
- data/README.md +169 -0
- data/RUNNING_TESTS.md +127 -0
- data/Rakefile +294 -5
- data/Rakefile.jdbc +20 -0
- data/activerecord-jdbc-adapter.gemspec +55 -0
- data/lib/active_record/connection_adapters/as400_adapter.rb +2 -0
- data/lib/active_record/connection_adapters/db2_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/firebird_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/mariadb_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +1 -0
- data/lib/activerecord-jdbc-adapter.rb +0 -5
- data/lib/arel/visitors/compat.rb +60 -0
- data/lib/arel/visitors/db2.rb +128 -6
- data/lib/arel/visitors/derby.rb +103 -10
- data/lib/arel/visitors/firebird.rb +79 -0
- data/lib/arel/visitors/h2.rb +25 -0
- data/lib/arel/visitors/hsqldb.rb +18 -10
- data/lib/arel/visitors/postgresql_jdbc.rb +6 -0
- data/lib/arel/visitors/sql_server.rb +225 -0
- data/lib/arel/visitors/sql_server/ng42.rb +293 -0
- data/lib/arjdbc.rb +11 -21
- data/lib/arjdbc/abstract/connection_management.rb +35 -0
- data/lib/arjdbc/abstract/core.rb +64 -0
- data/lib/arjdbc/abstract/database_statements.rb +64 -0
- data/lib/arjdbc/abstract/statement_cache.rb +58 -0
- data/lib/arjdbc/abstract/transaction_support.rb +86 -0
- data/lib/arjdbc/db2.rb +3 -1
- data/lib/arjdbc/db2/adapter.rb +630 -250
- data/lib/arjdbc/db2/as400.rb +130 -0
- data/lib/arjdbc/db2/column.rb +167 -0
- data/lib/arjdbc/db2/connection_methods.rb +44 -0
- data/lib/arjdbc/derby.rb +1 -5
- data/lib/arjdbc/derby/active_record_patch.rb +13 -0
- data/lib/arjdbc/derby/adapter.rb +409 -217
- data/lib/arjdbc/derby/connection_methods.rb +16 -14
- data/lib/arjdbc/derby/schema_creation.rb +15 -0
- data/lib/arjdbc/discover.rb +62 -50
- data/lib/arjdbc/firebird.rb +3 -1
- data/lib/arjdbc/firebird/adapter.rb +365 -62
- data/lib/arjdbc/firebird/connection_methods.rb +23 -0
- data/lib/arjdbc/h2.rb +2 -3
- data/lib/arjdbc/h2/adapter.rb +273 -6
- data/lib/arjdbc/h2/connection_methods.rb +23 -8
- data/lib/arjdbc/hsqldb.rb +2 -3
- data/lib/arjdbc/hsqldb/adapter.rb +204 -77
- data/lib/arjdbc/hsqldb/connection_methods.rb +24 -10
- data/lib/arjdbc/hsqldb/explain_support.rb +35 -0
- data/lib/arjdbc/hsqldb/schema_creation.rb +11 -0
- data/lib/arjdbc/informix.rb +4 -2
- data/lib/arjdbc/informix/adapter.rb +78 -54
- data/lib/arjdbc/informix/connection_methods.rb +8 -9
- data/lib/arjdbc/jdbc.rb +59 -2
- data/lib/arjdbc/jdbc/adapter.rb +356 -166
- data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
- data/lib/arjdbc/jdbc/adapter_require.rb +46 -0
- data/lib/arjdbc/jdbc/base_ext.rb +15 -0
- data/lib/arjdbc/jdbc/callbacks.rb +27 -18
- data/lib/arjdbc/jdbc/column.rb +79 -20
- data/lib/arjdbc/jdbc/connection.rb +5 -119
- data/lib/arjdbc/jdbc/connection_methods.rb +32 -4
- data/lib/arjdbc/jdbc/error.rb +65 -0
- data/lib/arjdbc/jdbc/extension.rb +41 -29
- data/lib/arjdbc/jdbc/java.rb +5 -6
- data/lib/arjdbc/jdbc/jdbc.rake +3 -126
- data/lib/arjdbc/jdbc/railtie.rb +2 -9
- data/lib/arjdbc/jdbc/rake_tasks.rb +3 -10
- data/lib/arjdbc/jdbc/serialized_attributes_helper.rb +3 -0
- data/lib/arjdbc/jdbc/type_cast.rb +166 -0
- data/lib/arjdbc/jdbc/type_converter.rb +35 -19
- data/lib/arjdbc/mssql.rb +6 -3
- data/lib/arjdbc/mssql/adapter.rb +630 -298
- data/lib/arjdbc/mssql/column.rb +200 -0
- data/lib/arjdbc/mssql/connection_methods.rb +66 -17
- data/lib/arjdbc/mssql/explain_support.rb +99 -0
- data/lib/arjdbc/mssql/limit_helpers.rb +189 -50
- data/lib/arjdbc/mssql/lock_methods.rb +77 -0
- data/lib/arjdbc/mssql/types.rb +343 -0
- data/lib/arjdbc/mssql/utils.rb +82 -0
- data/lib/arjdbc/mysql.rb +2 -3
- data/lib/arjdbc/mysql/adapter.rb +86 -356
- data/lib/arjdbc/mysql/connection_methods.rb +159 -23
- data/lib/arjdbc/oracle/adapter.rb +714 -263
- data/lib/arjdbc/postgresql.rb +2 -3
- data/lib/arjdbc/postgresql/_bc_time_cast_patch.rb +24 -0
- data/lib/arjdbc/postgresql/adapter.rb +570 -400
- 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/array_parser.rb +95 -0
- data/lib/arjdbc/postgresql/base/pgconn.rb +11 -0
- data/lib/arjdbc/postgresql/column.rb +51 -0
- data/lib/arjdbc/postgresql/connection_methods.rb +57 -18
- data/lib/arjdbc/postgresql/name.rb +24 -0
- data/lib/arjdbc/postgresql/oid_types.rb +192 -0
- data/lib/arjdbc/railtie.rb +11 -0
- data/lib/arjdbc/sqlite3.rb +2 -3
- data/lib/arjdbc/sqlite3/adapter.rb +518 -198
- data/lib/arjdbc/sqlite3/connection_methods.rb +49 -24
- data/lib/arjdbc/sybase.rb +2 -2
- data/lib/arjdbc/sybase/adapter.rb +7 -6
- data/lib/arjdbc/tasks.rb +13 -0
- data/lib/arjdbc/tasks/database_tasks.rb +52 -0
- data/lib/arjdbc/tasks/databases.rake +91 -0
- data/lib/arjdbc/tasks/databases3.rake +215 -0
- data/lib/arjdbc/tasks/databases4.rake +39 -0
- data/lib/arjdbc/tasks/db2_database_tasks.rb +104 -0
- data/lib/arjdbc/tasks/derby_database_tasks.rb +95 -0
- data/lib/arjdbc/tasks/h2_database_tasks.rb +31 -0
- data/lib/arjdbc/tasks/hsqldb_database_tasks.rb +70 -0
- data/lib/arjdbc/tasks/jdbc_database_tasks.rb +169 -0
- data/lib/arjdbc/tasks/mssql_database_tasks.rb +46 -0
- data/lib/arjdbc/util/quoted_cache.rb +60 -0
- data/lib/arjdbc/util/serialized_attributes.rb +98 -0
- data/lib/arjdbc/util/table_copier.rb +110 -0
- data/lib/arjdbc/version.rb +1 -6
- data/lib/generators/jdbc/USAGE +9 -0
- data/lib/generators/jdbc/jdbc_generator.rb +8 -0
- data/lib/jdbc_adapter.rb +1 -1
- data/lib/jdbc_adapter/rake_tasks.rb +3 -2
- data/lib/jdbc_adapter/version.rb +2 -1
- data/pom.xml +114 -0
- data/rails_generators/jdbc_generator.rb +1 -1
- data/rails_generators/templates/config/initializers/jdbc.rb +8 -5
- data/rails_generators/templates/lib/tasks/jdbc.rake +7 -4
- data/rakelib/01-tomcat.rake +51 -0
- data/rakelib/02-test.rake +132 -0
- data/rakelib/bundler_ext.rb +11 -0
- data/rakelib/compile.rake +67 -22
- data/rakelib/db.rake +61 -0
- data/rakelib/rails.rake +204 -29
- data/src/java/arjdbc/ArJdbcModule.java +286 -0
- data/src/java/arjdbc/db2/DB2Module.java +76 -0
- data/src/java/arjdbc/db2/DB2RubyJdbcConnection.java +126 -0
- data/src/java/arjdbc/derby/DerbyModule.java +99 -243
- data/src/java/arjdbc/derby/DerbyRubyJdbcConnection.java +152 -0
- data/src/java/arjdbc/firebird/FirebirdRubyJdbcConnection.java +174 -0
- data/src/java/arjdbc/{jdbc/JdbcConnectionFactory.java → h2/H2Module.java} +20 -6
- data/src/java/arjdbc/h2/H2RubyJdbcConnection.java +27 -12
- data/src/java/arjdbc/hsqldb/HSQLDBModule.java +73 -0
- data/src/java/arjdbc/informix/InformixRubyJdbcConnection.java +7 -6
- data/src/java/arjdbc/jdbc/AdapterJavaService.java +7 -29
- data/src/java/arjdbc/jdbc/Callable.java +44 -0
- data/src/java/arjdbc/jdbc/ConnectionFactory.java +132 -0
- data/src/java/arjdbc/jdbc/DataSourceConnectionFactory.java +157 -0
- data/src/java/arjdbc/jdbc/DriverConnectionFactory.java +63 -0
- data/src/java/arjdbc/jdbc/DriverWrapper.java +119 -0
- data/src/java/arjdbc/jdbc/JdbcResult.java +130 -0
- data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +3622 -948
- data/src/java/arjdbc/mssql/MSSQLModule.java +90 -0
- data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +181 -0
- data/src/java/arjdbc/mysql/MySQLModule.java +99 -81
- data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +294 -0
- data/src/java/arjdbc/oracle/OracleModule.java +80 -0
- data/src/java/arjdbc/oracle/OracleRubyJdbcConnection.java +387 -17
- data/src/java/arjdbc/postgresql/ByteaUtils.java +157 -0
- data/src/java/arjdbc/postgresql/PgResultSetMetaDataWrapper.java +23 -0
- data/src/java/arjdbc/postgresql/PostgreSQLModule.java +77 -0
- data/src/java/arjdbc/postgresql/PostgreSQLResult.java +184 -0
- data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +952 -0
- data/src/java/arjdbc/sqlite3/SQLite3Module.java +73 -0
- data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +525 -0
- data/src/java/arjdbc/util/CallResultSet.java +826 -0
- data/src/java/arjdbc/util/DateTimeUtils.java +580 -0
- data/src/java/arjdbc/util/ObjectSupport.java +65 -0
- data/src/java/arjdbc/util/QuotingUtils.java +138 -0
- data/src/java/arjdbc/util/StringCache.java +63 -0
- data/src/java/arjdbc/util/StringHelper.java +159 -0
- metadata +245 -268
- data/History.txt +0 -369
- data/Manifest.txt +0 -180
- data/README.txt +0 -181
- data/lib/active_record/connection_adapters/oracle_adapter.rb +0 -1
- data/lib/arel/engines/sql/compilers/db2_compiler.rb +0 -9
- data/lib/arel/engines/sql/compilers/derby_compiler.rb +0 -6
- data/lib/arel/engines/sql/compilers/h2_compiler.rb +0 -6
- data/lib/arel/engines/sql/compilers/hsqldb_compiler.rb +0 -15
- data/lib/arel/engines/sql/compilers/jdbc_compiler.rb +0 -6
- data/lib/arel/engines/sql/compilers/mssql_compiler.rb +0 -46
- data/lib/arel/visitors/mssql.rb +0 -44
- data/lib/arjdbc/jdbc/compatibility.rb +0 -51
- data/lib/arjdbc/jdbc/core_ext.rb +0 -24
- data/lib/arjdbc/jdbc/discover.rb +0 -18
- data/lib/arjdbc/jdbc/driver.rb +0 -44
- data/lib/arjdbc/jdbc/missing_functionality_helper.rb +0 -87
- data/lib/arjdbc/jdbc/quoted_primary_key.rb +0 -28
- data/lib/arjdbc/jdbc/require_driver.rb +0 -16
- data/lib/arjdbc/mimer.rb +0 -2
- data/lib/arjdbc/mimer/adapter.rb +0 -142
- data/lib/arjdbc/mssql/tsql_helper.rb +0 -61
- data/lib/arjdbc/oracle.rb +0 -3
- data/lib/arjdbc/oracle/connection_methods.rb +0 -11
- data/lib/pg.rb +0 -4
- data/rakelib/package.rake +0 -92
- data/rakelib/test.rake +0 -81
- data/src/java/arjdbc/jdbc/SQLBlock.java +0 -48
- data/src/java/arjdbc/mssql/MssqlRubyJdbcConnection.java +0 -127
- data/src/java/arjdbc/postgresql/PostgresqlRubyJdbcConnection.java +0 -57
- data/src/java/arjdbc/sqlite3/Sqlite3RubyJdbcConnection.java +0 -64
- data/test/abstract_db_create.rb +0 -117
- data/test/activerecord/connection_adapters/type_conversion_test.rb +0 -31
- data/test/activerecord/connections/native_jdbc_mysql/connection.rb +0 -25
- data/test/db/db2.rb +0 -11
- data/test/db/derby.rb +0 -12
- data/test/db/h2.rb +0 -11
- data/test/db/hsqldb.rb +0 -13
- data/test/db/informix.rb +0 -11
- data/test/db/jdbc.rb +0 -11
- data/test/db/jndi_config.rb +0 -40
- data/test/db/logger.rb +0 -3
- data/test/db/mssql.rb +0 -9
- data/test/db/mysql.rb +0 -10
- data/test/db/oracle.rb +0 -34
- data/test/db/postgres.rb +0 -9
- data/test/db/sqlite3.rb +0 -11
- data/test/db2_simple_test.rb +0 -66
- data/test/derby_migration_test.rb +0 -68
- data/test/derby_multibyte_test.rb +0 -12
- data/test/derby_simple_test.rb +0 -99
- data/test/generic_jdbc_connection_test.rb +0 -29
- data/test/h2_simple_test.rb +0 -41
- data/test/has_many_through.rb +0 -79
- data/test/helper.rb +0 -5
- data/test/hsqldb_simple_test.rb +0 -6
- data/test/informix_simple_test.rb +0 -48
- data/test/jdbc_common.rb +0 -25
- data/test/jndi_callbacks_test.rb +0 -40
- data/test/jndi_test.rb +0 -25
- data/test/manualTestDatabase.rb +0 -191
- data/test/models/add_not_null_column_to_table.rb +0 -12
- data/test/models/auto_id.rb +0 -18
- data/test/models/data_types.rb +0 -28
- data/test/models/entry.rb +0 -43
- data/test/models/mixed_case.rb +0 -25
- data/test/models/reserved_word.rb +0 -18
- data/test/models/string_id.rb +0 -18
- data/test/models/validates_uniqueness_of_string.rb +0 -19
- data/test/mssql_db_create_test.rb +0 -26
- data/test/mssql_identity_insert_test.rb +0 -19
- data/test/mssql_legacy_types_test.rb +0 -58
- data/test/mssql_limit_offset_test.rb +0 -136
- data/test/mssql_multibyte_test.rb +0 -18
- data/test/mssql_simple_test.rb +0 -55
- data/test/mysql_db_create_test.rb +0 -27
- data/test/mysql_info_test.rb +0 -113
- data/test/mysql_multibyte_test.rb +0 -10
- data/test/mysql_nonstandard_primary_key_test.rb +0 -42
- data/test/mysql_simple_test.rb +0 -49
- data/test/oracle_simple_test.rb +0 -18
- data/test/oracle_specific_test.rb +0 -83
- data/test/pick_rails_version.rb +0 -3
- data/test/postgres_db_create_test.rb +0 -32
- data/test/postgres_drop_db_test.rb +0 -16
- data/test/postgres_mixed_case_test.rb +0 -29
- data/test/postgres_nonseq_pkey_test.rb +0 -38
- data/test/postgres_reserved_test.rb +0 -22
- data/test/postgres_schema_search_path_test.rb +0 -44
- data/test/postgres_simple_test.rb +0 -51
- data/test/postgres_table_alias_length_test.rb +0 -15
- data/test/simple.rb +0 -546
- data/test/sqlite3_simple_test.rb +0 -233
- data/test/sybase_jtds_simple_test.rb +0 -28
data/rakelib/test.rake
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test/helper', __FILE__)
|
2
|
-
if defined?(JRUBY_VERSION)
|
3
|
-
databases = [:test_mysql, :test_jdbc, :test_sqlite3, :test_derby, :test_hsqldb, :test_h2]
|
4
|
-
if find_executable?("psql") && `psql -c '\\l'` && $?.exitstatus == 0
|
5
|
-
databases << :test_postgres
|
6
|
-
end
|
7
|
-
if File.exist?('test/fscontext.jar')
|
8
|
-
databases << :test_jndi
|
9
|
-
end
|
10
|
-
task :test => databases
|
11
|
-
else
|
12
|
-
task :test => [:test_mysql]
|
13
|
-
end
|
14
|
-
|
15
|
-
def declare_test_task_for(adapter, options = {})
|
16
|
-
driver = options[:driver] || adapter
|
17
|
-
Rake::TestTask.new("test_#{adapter}") do |t|
|
18
|
-
files = FileList["test/#{adapter}*test.rb"]
|
19
|
-
if adapter == "derby"
|
20
|
-
files << 'test/activerecord/connection_adapters/type_conversion_test.rb'
|
21
|
-
end
|
22
|
-
t.test_files = files
|
23
|
-
t.libs = []
|
24
|
-
if defined?(JRUBY_VERSION)
|
25
|
-
t.ruby_opts << "-rjdbc/#{driver}"
|
26
|
-
t.libs << "lib" << "drivers/#{driver}/lib"
|
27
|
-
t.libs.push *FileList["adapters/#{adapter}*/lib"]
|
28
|
-
end
|
29
|
-
t.libs << "test"
|
30
|
-
t.verbose = true
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
declare_test_task_for :derby
|
35
|
-
declare_test_task_for :h2
|
36
|
-
declare_test_task_for :hsqldb
|
37
|
-
declare_test_task_for :mssql, :driver => :jtds
|
38
|
-
declare_test_task_for :mysql
|
39
|
-
declare_test_task_for :postgres
|
40
|
-
declare_test_task_for :sqlite3
|
41
|
-
|
42
|
-
Rake::TestTask.new(:test_jdbc) do |t|
|
43
|
-
t.test_files = FileList['test/generic_jdbc_connection_test.rb']
|
44
|
-
t.libs << 'test' << 'drivers/mysql/lib'
|
45
|
-
end
|
46
|
-
|
47
|
-
Rake::TestTask.new(:test_jndi) do |t|
|
48
|
-
t.test_files = FileList['test/jndi*_test.rb']
|
49
|
-
t.libs << 'test' << 'drivers/derby/lib'
|
50
|
-
end
|
51
|
-
|
52
|
-
task :test_postgresql => [:test_postgres]
|
53
|
-
task :test_pgsql => [:test_postgres]
|
54
|
-
|
55
|
-
# Ensure driver for these DBs is on your classpath
|
56
|
-
%w(oracle db2 cachedb informix).each do |d|
|
57
|
-
Rake::TestTask.new("test_#{d}") do |t|
|
58
|
-
t.test_files = FileList["test/#{d}*_test.rb"]
|
59
|
-
t.libs = []
|
60
|
-
t.libs << 'lib' if defined?(JRUBY_VERSION)
|
61
|
-
t.libs << 'test'
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
# Tests for JDBC adapters that don't require a database.
|
66
|
-
Rake::TestTask.new(:test_jdbc_adapters) do | t |
|
67
|
-
t.test_files = FileList[ 'test/jdbc_adapter/jdbc_sybase_test.rb' ]
|
68
|
-
t.libs << 'test'
|
69
|
-
end
|
70
|
-
|
71
|
-
# Ensure that the jTDS driver is in your classpath before launching rake
|
72
|
-
Rake::TestTask.new(:test_sybase_jtds) do |t|
|
73
|
-
t.test_files = FileList['test/sybase_jtds_simple_test.rb']
|
74
|
-
t.libs << 'test'
|
75
|
-
end
|
76
|
-
|
77
|
-
# Ensure that the jConnect driver is in your classpath before launching rake
|
78
|
-
Rake::TestTask.new(:test_sybase_jconnect) do |t|
|
79
|
-
t.test_files = FileList['test/sybase_jconnect_simple_test.rb']
|
80
|
-
t.libs << 'test'
|
81
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
**** BEGIN LICENSE BLOCK *****
|
3
|
-
* Copyright (c) 2006-2010 Nick Sieger <nick@nicksieger.com>
|
4
|
-
* Copyright (c) 2006-2007 Ola Bini <ola.bini@gmail.com>
|
5
|
-
* Copyright (c) 2008-2009 Thomas E Enebo <enebo@acm.org>
|
6
|
-
*
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
8
|
-
* a copy of this software and associated documentation files (the
|
9
|
-
* "Software"), to deal in the Software without restriction, including
|
10
|
-
* without limitation the rights to use, copy, modify, merge, publish,
|
11
|
-
* distribute, sublicense, and/or sell copies of the Software, and to
|
12
|
-
* permit persons to whom the Software is furnished to do so, subject to
|
13
|
-
* the following conditions:
|
14
|
-
*
|
15
|
-
* The above copyright notice and this permission notice shall be
|
16
|
-
* included in all copies or substantial portions of the Software.
|
17
|
-
*
|
18
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
19
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
20
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
-
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
22
|
-
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
23
|
-
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
24
|
-
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25
|
-
***** END LICENSE BLOCK *****/
|
26
|
-
|
27
|
-
package arjdbc.jdbc;
|
28
|
-
|
29
|
-
import java.sql.Connection;
|
30
|
-
import java.sql.ResultSet;
|
31
|
-
import java.sql.SQLException;
|
32
|
-
import java.sql.Statement;
|
33
|
-
|
34
|
-
/**
|
35
|
-
*
|
36
|
-
* @author nicksieger
|
37
|
-
*/
|
38
|
-
public abstract class SQLBlock {
|
39
|
-
abstract Object call(Connection c) throws SQLException;
|
40
|
-
|
41
|
-
public void close(Statement statement) {
|
42
|
-
RubyJdbcConnection.close(statement);
|
43
|
-
}
|
44
|
-
|
45
|
-
public void close(ResultSet resultSet) {
|
46
|
-
RubyJdbcConnection.close(resultSet);
|
47
|
-
}
|
48
|
-
}
|
@@ -1,127 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
**** BEGIN LICENSE BLOCK *****
|
3
|
-
* Copyright (c) 2006-2010 Nick Sieger <nick@nicksieger.com>
|
4
|
-
* Copyright (c) 2006-2007 Ola Bini <ola.bini@gmail.com>
|
5
|
-
* Copyright (c) 2008-2009 Thomas E Enebo <enebo@acm.org>
|
6
|
-
*
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
8
|
-
* a copy of this software and associated documentation files (the
|
9
|
-
* "Software"), to deal in the Software without restriction, including
|
10
|
-
* without limitation the rights to use, copy, modify, merge, publish,
|
11
|
-
* distribute, sublicense, and/or sell copies of the Software, and to
|
12
|
-
* permit persons to whom the Software is furnished to do so, subject to
|
13
|
-
* the following conditions:
|
14
|
-
*
|
15
|
-
* The above copyright notice and this permission notice shall be
|
16
|
-
* included in all copies or substantial portions of the Software.
|
17
|
-
*
|
18
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
19
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
20
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
-
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
22
|
-
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
23
|
-
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
24
|
-
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25
|
-
***** END LICENSE BLOCK *****/
|
26
|
-
package arjdbc.mssql;
|
27
|
-
|
28
|
-
import java.sql.ResultSet;
|
29
|
-
import java.sql.SQLException;
|
30
|
-
import java.sql.Types;
|
31
|
-
import java.util.List;
|
32
|
-
|
33
|
-
import arjdbc.jdbc.RubyJdbcConnection;
|
34
|
-
import static arjdbc.jdbc.RubyJdbcConnection.ColumnData;
|
35
|
-
|
36
|
-
import org.jruby.Ruby;
|
37
|
-
import org.jruby.RubyClass;
|
38
|
-
import org.jruby.RubyString;
|
39
|
-
import org.jruby.runtime.ObjectAllocator;
|
40
|
-
import org.jruby.runtime.ThreadContext;
|
41
|
-
import org.jruby.runtime.builtin.IRubyObject;
|
42
|
-
|
43
|
-
/**
|
44
|
-
*
|
45
|
-
* @author nicksieger
|
46
|
-
*/
|
47
|
-
public class MssqlRubyJdbcConnection extends RubyJdbcConnection {
|
48
|
-
|
49
|
-
private RubyString _row_num;
|
50
|
-
|
51
|
-
protected MssqlRubyJdbcConnection(Ruby runtime, RubyClass metaClass) {
|
52
|
-
super(runtime, metaClass);
|
53
|
-
_row_num = runtime.newString("_row_num");
|
54
|
-
}
|
55
|
-
|
56
|
-
public static RubyClass createMssqlJdbcConnectionClass(Ruby runtime, RubyClass jdbcConnection) {
|
57
|
-
RubyClass clazz = RubyJdbcConnection.getConnectionAdapters(runtime).defineClassUnder("MssqlJdbcConnection",
|
58
|
-
jdbcConnection, MSSQL_JDBCCONNECTION_ALLOCATOR);
|
59
|
-
clazz.defineAnnotatedMethods(MssqlRubyJdbcConnection.class);
|
60
|
-
|
61
|
-
return clazz;
|
62
|
-
}
|
63
|
-
|
64
|
-
private static ObjectAllocator MSSQL_JDBCCONNECTION_ALLOCATOR = new ObjectAllocator() {
|
65
|
-
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
|
66
|
-
return new MssqlRubyJdbcConnection(runtime, klass);
|
67
|
-
}
|
68
|
-
};
|
69
|
-
|
70
|
-
protected static IRubyObject booleanToRuby(Ruby runtime, ResultSet resultSet, boolean booleanValue)
|
71
|
-
throws SQLException {
|
72
|
-
if (booleanValue == false && resultSet.wasNull()) return runtime.getNil();
|
73
|
-
return runtime.newBoolean(booleanValue);
|
74
|
-
}
|
75
|
-
|
76
|
-
/**
|
77
|
-
* Treat LONGVARCHAR as CLOB on Mssql for purposes of converting a JDBC value to Ruby.
|
78
|
-
* Treat BOOLEAN/BIT as Boolean, rather than the default behaviour of conversion to string
|
79
|
-
*/
|
80
|
-
@Override
|
81
|
-
protected IRubyObject jdbcToRuby(Ruby runtime, int column, int type, ResultSet resultSet)
|
82
|
-
throws SQLException {
|
83
|
-
if ( Types.BOOLEAN == type || Types.BIT == type ) {
|
84
|
-
return booleanToRuby(runtime, resultSet, resultSet.getBoolean(column));
|
85
|
-
}
|
86
|
-
if (type == Types.LONGVARCHAR) {
|
87
|
-
type = Types.CLOB;
|
88
|
-
}
|
89
|
-
return super.jdbcToRuby(runtime, column, type, resultSet);
|
90
|
-
}
|
91
|
-
|
92
|
-
/**
|
93
|
-
* Microsoft SQL 2000+ support schemas
|
94
|
-
*/
|
95
|
-
@Override
|
96
|
-
protected boolean databaseSupportsSchemas() {
|
97
|
-
return true;
|
98
|
-
}
|
99
|
-
|
100
|
-
@Override
|
101
|
-
protected void populateFromResultSet(ThreadContext context, Ruby runtime, List results,
|
102
|
-
ResultSet resultSet, ColumnData[] columns) throws SQLException {
|
103
|
-
super.populateFromResultSet(context, runtime, results, resultSet, filterRowNumFromColumns(columns));
|
104
|
-
}
|
105
|
-
|
106
|
-
/**
|
107
|
-
* Filter out the <tt>_row_num</tt> column from results.
|
108
|
-
*/
|
109
|
-
private ColumnData[] filterRowNumFromColumns(ColumnData[] columns) {
|
110
|
-
for (int i = 0; i < columns.length; i++) {
|
111
|
-
if (columns[i].name.equals(_row_num)) {
|
112
|
-
ColumnData[] filtered = new ColumnData[columns.length - 1];
|
113
|
-
if (i > 0) {
|
114
|
-
System.arraycopy(columns, 0, filtered, 0, i);
|
115
|
-
}
|
116
|
-
|
117
|
-
if (i + 1 < columns.length) {
|
118
|
-
System.arraycopy(columns, i + 1, filtered, i, columns.length - (i + 1));
|
119
|
-
}
|
120
|
-
|
121
|
-
return filtered;
|
122
|
-
}
|
123
|
-
}
|
124
|
-
|
125
|
-
return columns;
|
126
|
-
}
|
127
|
-
}
|
@@ -1,57 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
**** BEGIN LICENSE BLOCK *****
|
3
|
-
* Copyright (c) 2006-2010 Nick Sieger <nick@nicksieger.com>
|
4
|
-
* Copyright (c) 2006-2007 Ola Bini <ola.bini@gmail.com>
|
5
|
-
* Copyright (c) 2008-2009 Thomas E Enebo <enebo@acm.org>
|
6
|
-
*
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
8
|
-
* a copy of this software and associated documentation files (the
|
9
|
-
* "Software"), to deal in the Software without restriction, including
|
10
|
-
* without limitation the rights to use, copy, modify, merge, publish,
|
11
|
-
* distribute, sublicense, and/or sell copies of the Software, and to
|
12
|
-
* permit persons to whom the Software is furnished to do so, subject to
|
13
|
-
* the following conditions:
|
14
|
-
*
|
15
|
-
* The above copyright notice and this permission notice shall be
|
16
|
-
* included in all copies or substantial portions of the Software.
|
17
|
-
*
|
18
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
19
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
20
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
-
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
22
|
-
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
23
|
-
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
24
|
-
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25
|
-
***** END LICENSE BLOCK *****/
|
26
|
-
package arjdbc.postgresql;
|
27
|
-
|
28
|
-
import arjdbc.jdbc.RubyJdbcConnection;
|
29
|
-
|
30
|
-
import org.jruby.Ruby;
|
31
|
-
import org.jruby.RubyClass;
|
32
|
-
import org.jruby.runtime.ObjectAllocator;
|
33
|
-
import org.jruby.runtime.builtin.IRubyObject;
|
34
|
-
|
35
|
-
/**
|
36
|
-
*
|
37
|
-
* @author enebo
|
38
|
-
*/
|
39
|
-
public class PostgresqlRubyJdbcConnection extends RubyJdbcConnection {
|
40
|
-
protected PostgresqlRubyJdbcConnection(Ruby runtime, RubyClass metaClass) {
|
41
|
-
super(runtime, metaClass);
|
42
|
-
}
|
43
|
-
|
44
|
-
public static RubyClass createPostgresqlJdbcConnectionClass(Ruby runtime, RubyClass jdbcConnection) {
|
45
|
-
RubyClass clazz = RubyJdbcConnection.getConnectionAdapters(runtime).defineClassUnder("PostgresJdbcConnection",
|
46
|
-
jdbcConnection, POSTGRESQL_JDBCCONNECTION_ALLOCATOR);
|
47
|
-
clazz.defineAnnotatedMethods(PostgresqlRubyJdbcConnection.class);
|
48
|
-
|
49
|
-
return clazz;
|
50
|
-
}
|
51
|
-
|
52
|
-
private static ObjectAllocator POSTGRESQL_JDBCCONNECTION_ALLOCATOR = new ObjectAllocator() {
|
53
|
-
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
|
54
|
-
return new PostgresqlRubyJdbcConnection(runtime, klass);
|
55
|
-
}
|
56
|
-
};
|
57
|
-
}
|
@@ -1,64 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
**** BEGIN LICENSE BLOCK *****
|
3
|
-
* Copyright (c) 2006-2010 Nick Sieger <nick@nicksieger.com>
|
4
|
-
* Copyright (c) 2006-2007 Ola Bini <ola.bini@gmail.com>
|
5
|
-
* Copyright (c) 2008-2009 Thomas E Enebo <enebo@acm.org>
|
6
|
-
*
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
8
|
-
* a copy of this software and associated documentation files (the
|
9
|
-
* "Software"), to deal in the Software without restriction, including
|
10
|
-
* without limitation the rights to use, copy, modify, merge, publish,
|
11
|
-
* distribute, sublicense, and/or sell copies of the Software, and to
|
12
|
-
* permit persons to whom the Software is furnished to do so, subject to
|
13
|
-
* the following conditions:
|
14
|
-
*
|
15
|
-
* The above copyright notice and this permission notice shall be
|
16
|
-
* included in all copies or substantial portions of the Software.
|
17
|
-
*
|
18
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
19
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
20
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
-
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
22
|
-
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
23
|
-
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
24
|
-
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25
|
-
***** END LICENSE BLOCK *****/
|
26
|
-
|
27
|
-
package arjdbc.sqlite3;
|
28
|
-
|
29
|
-
import arjdbc.jdbc.RubyJdbcConnection;
|
30
|
-
|
31
|
-
import org.jruby.Ruby;
|
32
|
-
import org.jruby.RubyClass;
|
33
|
-
import org.jruby.runtime.ObjectAllocator;
|
34
|
-
import org.jruby.runtime.ThreadContext;
|
35
|
-
import org.jruby.runtime.builtin.IRubyObject;
|
36
|
-
|
37
|
-
/**
|
38
|
-
*
|
39
|
-
* @author enebo
|
40
|
-
*/
|
41
|
-
public class Sqlite3RubyJdbcConnection extends RubyJdbcConnection {
|
42
|
-
protected Sqlite3RubyJdbcConnection(Ruby runtime, RubyClass metaClass) {
|
43
|
-
super(runtime, metaClass);
|
44
|
-
}
|
45
|
-
|
46
|
-
public static RubyClass createSqlite3JdbcConnectionClass(Ruby runtime, RubyClass jdbcConnection) {
|
47
|
-
RubyClass clazz = RubyJdbcConnection.getConnectionAdapters(runtime).defineClassUnder("Sqlite3JdbcConnection",
|
48
|
-
jdbcConnection, SQLITE3_JDBCCONNECTION_ALLOCATOR);
|
49
|
-
clazz.defineAnnotatedMethods(Sqlite3RubyJdbcConnection.class);
|
50
|
-
|
51
|
-
return clazz;
|
52
|
-
}
|
53
|
-
|
54
|
-
private static ObjectAllocator SQLITE3_JDBCCONNECTION_ALLOCATOR = new ObjectAllocator() {
|
55
|
-
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
|
56
|
-
return new Sqlite3RubyJdbcConnection(runtime, klass);
|
57
|
-
}
|
58
|
-
};
|
59
|
-
|
60
|
-
@Override
|
61
|
-
protected IRubyObject tables(ThreadContext context, String catalog, String schemaPattern, String tablePattern, String[] types) {
|
62
|
-
return (IRubyObject) withConnectionAndRetry(context, tableLookupBlock(context.getRuntime(), catalog, schemaPattern, tablePattern, types, true));
|
63
|
-
}
|
64
|
-
}
|
data/test/abstract_db_create.rb
DELETED
@@ -1,117 +0,0 @@
|
|
1
|
-
require 'jdbc_common'
|
2
|
-
require 'rake'
|
3
|
-
|
4
|
-
module Rails
|
5
|
-
class Configuration
|
6
|
-
end
|
7
|
-
class Application
|
8
|
-
def self.config
|
9
|
-
@config ||= Object.new
|
10
|
-
end
|
11
|
-
end
|
12
|
-
def self.application
|
13
|
-
Rails::Application
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
module AbstractDbCreate
|
18
|
-
def setup
|
19
|
-
@prevapp = Rake.application
|
20
|
-
Rake.application = Rake::Application.new
|
21
|
-
verbose(true)
|
22
|
-
@prevconfigs = ActiveRecord::Base.configurations
|
23
|
-
ActiveRecord::Base.connection.disconnect!
|
24
|
-
@db_name = 'test_rake_db_create'
|
25
|
-
setup_rails
|
26
|
-
set_rails_constant("env", "unittest")
|
27
|
-
set_rails_constant("root", ".")
|
28
|
-
load File.dirname(__FILE__) + '/../lib/arjdbc/jdbc/jdbc.rake' if jruby?
|
29
|
-
task :environment do
|
30
|
-
ActiveRecord::Base.configurations = configurations
|
31
|
-
@full_env_loaded = true
|
32
|
-
end
|
33
|
-
task :rails_env do
|
34
|
-
@rails_env_set = true
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def teardown
|
39
|
-
Rake::Task["db:drop"].invoke
|
40
|
-
Rake.application = @prevapp
|
41
|
-
restore_rails
|
42
|
-
ActiveRecord::Base.configurations = @prevconfigs
|
43
|
-
ActiveRecord::Base.establish_connection(db_config)
|
44
|
-
@rails_env_set = nil
|
45
|
-
@full_env_loaded = nil
|
46
|
-
end
|
47
|
-
|
48
|
-
def setup_rails
|
49
|
-
if ActiveRecord::VERSION::MAJOR == 3
|
50
|
-
setup_rails3
|
51
|
-
else
|
52
|
-
setup_rails2
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def configurations
|
57
|
-
the_db_name = @db_name
|
58
|
-
the_db_config = db_config
|
59
|
-
@configs = { "unittest" => the_db_config.merge({:database => the_db_name}).stringify_keys! }
|
60
|
-
@configs["test"] = @configs["unittest"].dup
|
61
|
-
@configs
|
62
|
-
end
|
63
|
-
|
64
|
-
def setup_rails2
|
65
|
-
configs = configurations
|
66
|
-
Rails::Configuration.class_eval do
|
67
|
-
define_method(:database_configuration) { configs }
|
68
|
-
end
|
69
|
-
ar_version = $LOADED_FEATURES.grep(%r{active_record/version}).first
|
70
|
-
ar_lib_path = $LOAD_PATH.detect {|p| p if File.exist?File.join(p, ar_version)}
|
71
|
-
ar_lib_path = ar_lib_path.sub(%r{activerecord/lib}, 'railties/lib') # edge rails
|
72
|
-
rails_lib_path = ar_lib_path.sub(/activerecord/, 'rails') # gem rails
|
73
|
-
load "#{rails_lib_path}/tasks/databases.rake"
|
74
|
-
end
|
75
|
-
|
76
|
-
def setup_rails3
|
77
|
-
configs = configurations
|
78
|
-
(class << Rails::Application.config; self ; end).instance_eval do
|
79
|
-
define_method(:database_configuration) { configs }
|
80
|
-
end
|
81
|
-
ar_version = $LOADED_FEATURES.grep(%r{active_record/version}).first
|
82
|
-
ar_lib_path = $LOAD_PATH.detect {|p| p if File.exist?File.join(p, ar_version)}
|
83
|
-
load "#{ar_lib_path}/active_record/railties/databases.rake"
|
84
|
-
end
|
85
|
-
|
86
|
-
def set_rails_constant(name, value)
|
87
|
-
cname ="RAILS_#{name.upcase}"
|
88
|
-
@constants ||= {}
|
89
|
-
@constants[name] = Object.const_get(cname) rescue nil
|
90
|
-
silence_warnings { Object.const_set(cname, value) }
|
91
|
-
Rails.instance_eval do
|
92
|
-
if instance_methods(false).include?(name)
|
93
|
-
alias_method "orig_#{name}", name
|
94
|
-
define_method(name) { value }
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def restore_rails
|
100
|
-
@constants.each do |key,value|
|
101
|
-
silence_warnings { Object.const_set("RAILS_#{key.upcase}", value) }
|
102
|
-
Rails.instance_eval do
|
103
|
-
if instance_methods(false).include?(name)
|
104
|
-
remove_method name
|
105
|
-
alias_method name, "orig_#{name}"
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def silence_warnings
|
112
|
-
prev, $VERBOSE = $VERBOSE, nil
|
113
|
-
yield
|
114
|
-
ensure
|
115
|
-
$VERBOSE = prev
|
116
|
-
end
|
117
|
-
end
|