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/README.txt
DELETED
@@ -1,181 +0,0 @@
|
|
1
|
-
activerecord-jdbc-adapter is a database adapter for Rails' ActiveRecord
|
2
|
-
component that can be used with JRuby[http://www.jruby.org/]. It allows use of
|
3
|
-
virtually any JDBC-compliant database with your JRuby on Rails application.
|
4
|
-
|
5
|
-
== Databases
|
6
|
-
|
7
|
-
Activerecord-jdbc-adapter provides full or nearly full support for:
|
8
|
-
MySQL, PostgreSQL, SQLite3, Oracle, Microsoft SQL Server, DB2,
|
9
|
-
FireBird, Derby, HSQLDB, H2, and Informix.
|
10
|
-
|
11
|
-
Other databases will require testing and likely a custom configuration module.
|
12
|
-
Please join the activerecord-jdbc
|
13
|
-
mailing-lists[http://kenai.com/projects/activerecord-jdbc/lists] to help us discover
|
14
|
-
support for more databases.
|
15
|
-
|
16
|
-
== Using ActiveRecord JDBC
|
17
|
-
|
18
|
-
=== Inside Rails
|
19
|
-
|
20
|
-
To use activerecord-jdbc-adapter with JRuby on Rails:
|
21
|
-
|
22
|
-
1. Choose the adapter you wish to gem install. The following pre-packaged
|
23
|
-
adapters are available:
|
24
|
-
|
25
|
-
* base jdbc (<tt>activerecord-jdbc-adapter</tt>). Supports all available databases via JDBC, but requires you to download and manually install the database vendor's JDBC driver .jar file.
|
26
|
-
* mysql (<tt>activerecord-jdbcmysql-adapter</tt>)
|
27
|
-
* postgresql (<tt>activerecord-jdbcpostgresql-adapter</tt>)
|
28
|
-
* sqlite3 (<tt>activerecord-jdbcsqlite3-adapter</tt>)
|
29
|
-
* derby (<tt>activerecord-jdbcderby-adapter</tt>)
|
30
|
-
* hsqldb (<tt>activerecord-jdbchsqldb-adapter</tt>)
|
31
|
-
* h2 (<tt>activerecord-jdbch2-adapter</tt>)
|
32
|
-
* mssql (<tt>activerecord-jdbcmssql-adapter</tt>)
|
33
|
-
|
34
|
-
2a. For Rails 3, if you're generating a new application, use the
|
35
|
-
following command to generate your application:
|
36
|
-
|
37
|
-
jruby -S rails new sweetapp -m http://jruby.org/rails3.rb
|
38
|
-
|
39
|
-
2b. Otherwise, you'll need to perform some extra configuration steps
|
40
|
-
to prepare your Rails application for JDBC.
|
41
|
-
|
42
|
-
If you're using Rails 3, you'll need to modify your Gemfile to use the
|
43
|
-
activerecord-jdbc-adapter gem under JRuby. Change your Gemfile to look
|
44
|
-
like the following (using sqlite3 as an example):
|
45
|
-
|
46
|
-
if defined?(JRUBY_VERSION)
|
47
|
-
gem 'activerecord-jdbc-adapter'
|
48
|
-
gem 'jdbc-sqlite3'
|
49
|
-
else
|
50
|
-
gem 'sqlite3-ruby', :require => 'sqlite3'
|
51
|
-
end
|
52
|
-
|
53
|
-
If you're using Rails 2:
|
54
|
-
|
55
|
-
jruby script/generate jdbc
|
56
|
-
|
57
|
-
3. Configure your database.yml in the normal Rails style.
|
58
|
-
|
59
|
-
Legacy configuration: If you use one of the convenience
|
60
|
-
'activerecord-jdbcXXX-adapter' adapters, you can still put a 'jdbc'
|
61
|
-
prefix in front of the database adapter name as below.
|
62
|
-
|
63
|
-
development:
|
64
|
-
adapter: jdbcmysql
|
65
|
-
username: blog
|
66
|
-
password:
|
67
|
-
hostname: localhost
|
68
|
-
database: weblog_development
|
69
|
-
|
70
|
-
For other databases, you'll need to know the database driver class and
|
71
|
-
URL. Example:
|
72
|
-
|
73
|
-
development:
|
74
|
-
adapter: jdbc
|
75
|
-
username: blog
|
76
|
-
password:
|
77
|
-
driver: com.mysql.jdbc.Driver
|
78
|
-
url: jdbc:mysql://localhost:3306/weblog_development
|
79
|
-
|
80
|
-
For JNDI data sources, you may simply specify the JNDI location as follows
|
81
|
-
(the adapter will be automatically detected):
|
82
|
-
|
83
|
-
production:
|
84
|
-
adapter: jdbc
|
85
|
-
jndi: jdbc/mysqldb
|
86
|
-
|
87
|
-
=== Standalone, with ActiveRecord
|
88
|
-
|
89
|
-
1. Install the gem with JRuby:
|
90
|
-
|
91
|
-
jruby -S gem install activerecord-jdbc-adapter
|
92
|
-
|
93
|
-
If you wish to use the adapter for a specific database, you can
|
94
|
-
install it directly and a driver gem will be installed as well:
|
95
|
-
|
96
|
-
jruby -S gem install activerecord-jdbcderby-adapter
|
97
|
-
|
98
|
-
2. After this you can establish a JDBC connection like this:
|
99
|
-
|
100
|
-
ActiveRecord::Base.establish_connection(
|
101
|
-
:adapter => 'jdbcderby',
|
102
|
-
:database => "db/my-database"
|
103
|
-
)
|
104
|
-
|
105
|
-
or like this (but requires that you manually put the driver jar on the classpath):
|
106
|
-
|
107
|
-
ActiveRecord::Base.establish_connection(
|
108
|
-
:adapter => 'jdbc',
|
109
|
-
:driver => 'org.apache.derby.jdbc.EmbeddedDriver',
|
110
|
-
:url => 'jdbc:derby:test_ar;create=true'
|
111
|
-
)
|
112
|
-
|
113
|
-
== Extending AR-JDBC
|
114
|
-
|
115
|
-
You can create your own extension to AR-JDBC for a JDBC-based database
|
116
|
-
that core AR-JDBC does not support. We've created an example project
|
117
|
-
for the Intersystems Cache database that you can examine as a
|
118
|
-
template. See the project for more information at the following URL:
|
119
|
-
|
120
|
-
http://github.com/nicksieger/activerecord-cachedb-adapter
|
121
|
-
|
122
|
-
== Getting the source
|
123
|
-
|
124
|
-
The source for activerecord-jdbc-adapter is available using git.
|
125
|
-
|
126
|
-
git clone git://github.com/nicksieger/activerecord-jdbc-adapter.git
|
127
|
-
|
128
|
-
== Feedback
|
129
|
-
|
130
|
-
Please file bug reports at
|
131
|
-
http://kenai.com/jira/browse/ACTIVERECORD_JDBC. If you're not sure if
|
132
|
-
something's a bug, feel free to pre-report it on the mailing lists.
|
133
|
-
|
134
|
-
== Project Info
|
135
|
-
|
136
|
-
* Mailing Lists: http://kenai.com/projects/activerecord-jdbc/lists
|
137
|
-
* Issues: http://kenai.com/jira/browse/ACTIVERECORD_JDBC
|
138
|
-
* Source:
|
139
|
-
git://github.com/nicksieger/activerecord-jdbc-adapter.git
|
140
|
-
git://kenai.com/activerecord-jdbc~main
|
141
|
-
|
142
|
-
== Running AR-JDBC's Tests
|
143
|
-
|
144
|
-
Drivers for 6 open-source databases are included. Provided you have
|
145
|
-
MySQL installed, you can simply type <tt>jruby -S rake</tt> to run the
|
146
|
-
tests. A database named <tt>weblog_development</tt> is needed
|
147
|
-
beforehand with a connection user of "blog" and an empty password. You
|
148
|
-
alse need to grant "blog" create privileges on
|
149
|
-
'test_rake_db_create.*'.
|
150
|
-
|
151
|
-
If you also have PostgreSQL available, those tests will be run if the
|
152
|
-
`psql' executable can be found. Also ensure you have a database named
|
153
|
-
<tt>weblog_development</tt> and a user named "blog" and an empty
|
154
|
-
password.
|
155
|
-
|
156
|
-
If you want rails logging enabled during these test runs you can edit
|
157
|
-
test/jdbc_common.rb and add the following line:
|
158
|
-
|
159
|
-
require 'db/logger'
|
160
|
-
|
161
|
-
== Running AR Tests
|
162
|
-
|
163
|
-
To run the current AR-JDBC sources with ActiveRecord, just use the
|
164
|
-
included "rails:test" task. Be sure to specify a driver and a path to
|
165
|
-
the ActiveRecord sources.
|
166
|
-
|
167
|
-
jruby -S rake rails:test DRIVER=mysql RAILS=/path/activerecord_source_dir
|
168
|
-
|
169
|
-
== Authors
|
170
|
-
|
171
|
-
This project was written by Nick Sieger <nick@nicksieger.com> and Ola Bini
|
172
|
-
<olabini@gmail.com> with lots of help from the JRuby community.
|
173
|
-
|
174
|
-
== License
|
175
|
-
|
176
|
-
activerecord-jdbc-adapter is released under a BSD license. See the LICENSE file
|
177
|
-
included with the distribution for details.
|
178
|
-
|
179
|
-
Open-source driver gems for activerecord-jdbc-adapter are licensed under the
|
180
|
-
same license the database's drivers are licensed. See each driver gem's
|
181
|
-
LICENSE.txt file for details.
|
@@ -1 +0,0 @@
|
|
1
|
-
require 'arjdbc/oracle'
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Arel
|
2
|
-
module SqlCompiler
|
3
|
-
class HsqldbCompiler < GenericCompiler
|
4
|
-
def select_sql
|
5
|
-
# HSQLDB needs to add LIMIT in right after SELECT
|
6
|
-
query = super
|
7
|
-
offset = relation.skipped
|
8
|
-
limit = relation.taken
|
9
|
-
@engine.connection.add_limit_offset!(query, :limit => limit,
|
10
|
-
:offset => offset) if offset || limit
|
11
|
-
query
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
module Arel
|
2
|
-
module SqlCompiler
|
3
|
-
class MsSQLCompiler < GenericCompiler
|
4
|
-
def select_sql
|
5
|
-
projections = @relation.projections
|
6
|
-
offset = relation.skipped
|
7
|
-
limit = relation.taken
|
8
|
-
if Count === projections.first && projections.size == 1 &&
|
9
|
-
(relation.taken.present? || relation.wheres.present?) && relation.joins(self).blank?
|
10
|
-
subquery = [
|
11
|
-
"SELECT * FROM #{relation.from_clauses}", build_clauses
|
12
|
-
].join ' '
|
13
|
-
@engine.connection.add_limit_offset!(subquery, :limit => limit, :offset => offset) if offset || limit
|
14
|
-
query = "SELECT COUNT(*) AS count_id FROM (#{subquery}) AS subquery"
|
15
|
-
else
|
16
|
-
query = [
|
17
|
-
"SELECT #{relation.select_clauses.join(', ')}",
|
18
|
-
"FROM #{relation.from_clauses}",
|
19
|
-
build_clauses
|
20
|
-
].compact.join ' '
|
21
|
-
@engine.connection.add_limit_offset!(query, :limit => limit, :offset => offset) if offset || limit
|
22
|
-
end
|
23
|
-
query
|
24
|
-
end
|
25
|
-
|
26
|
-
def build_clauses
|
27
|
-
joins = relation.joins(self)
|
28
|
-
wheres = relation.where_clauses
|
29
|
-
groups = relation.group_clauses
|
30
|
-
havings = relation.having_clauses
|
31
|
-
orders = relation.order_clauses
|
32
|
-
|
33
|
-
clauses = [ "",
|
34
|
-
joins,
|
35
|
-
("WHERE #{wheres.join(' AND ')}" unless wheres.empty?),
|
36
|
-
("GROUP BY #{groups.join(', ')}" unless groups.empty?),
|
37
|
-
("HAVING #{havings.join(' AND ')}" unless havings.empty?),
|
38
|
-
("ORDER BY #{orders.join(', ')}" unless orders.empty?)
|
39
|
-
].compact.join ' '
|
40
|
-
|
41
|
-
clauses << " #{locked}" unless locked.blank?
|
42
|
-
clauses unless clauses.blank?
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
data/lib/arel/visitors/mssql.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
module Arel
|
2
|
-
module Visitors
|
3
|
-
class SQLServer < Arel::Visitors::ToSql
|
4
|
-
include ArJdbc::MsSQL::LimitHelpers::SqlServerReplaceLimitOffset
|
5
|
-
|
6
|
-
def select_count? o
|
7
|
-
sel = o.cores.length == 1 && o.cores.first
|
8
|
-
projections = sel.projections.length == 1 && sel.projections
|
9
|
-
Arel::Nodes::Count === projections.first
|
10
|
-
end
|
11
|
-
|
12
|
-
# Need to mimic the subquery logic in ARel 1.x for select count with limit
|
13
|
-
# See arel/engines/sql/compilers/mssql_compiler.rb for details
|
14
|
-
def visit_Arel_Nodes_SelectStatement o
|
15
|
-
order = "ORDER BY #{o.orders.map { |x| visit x }.join(', ')}" unless o.orders.empty?
|
16
|
-
if o.limit
|
17
|
-
if select_count?(o)
|
18
|
-
subquery = true
|
19
|
-
sql = o.cores.map do |x|
|
20
|
-
x = x.dup
|
21
|
-
x.projections = [Arel::Nodes::SqlLiteral.new("*")]
|
22
|
-
visit_Arel_Nodes_SelectCore x
|
23
|
-
end.join
|
24
|
-
else
|
25
|
-
sql = o.cores.map { |x| visit_Arel_Nodes_SelectCore x }.join
|
26
|
-
end
|
27
|
-
|
28
|
-
order ||= "ORDER BY #{@connection.determine_order_clause(sql)}"
|
29
|
-
replace_limit_offset!(sql, o.limit.to_i, o.offset && o.offset.value.to_i, order)
|
30
|
-
sql = "SELECT COUNT(*) AS count_id FROM (#{sql}) AS subquery" if subquery
|
31
|
-
elsif order
|
32
|
-
sql << " #{order}"
|
33
|
-
else
|
34
|
-
sql = super
|
35
|
-
end
|
36
|
-
sql
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
class SQLServer2000 < SQLServer
|
41
|
-
include ArJdbc::MsSQL::LimitHelpers::SqlServer2000ReplaceLimitOffset
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# AR's 2.2 version of this method is sufficient, but we need it for
|
2
|
-
# older versions
|
3
|
-
if ActiveRecord::VERSION::MAJOR <= 2 && ActiveRecord::VERSION::MINOR < 2
|
4
|
-
module ActiveRecord
|
5
|
-
module ConnectionAdapters # :nodoc:
|
6
|
-
module SchemaStatements
|
7
|
-
# Convert the speficied column type to a SQL string.
|
8
|
-
def type_to_sql(type, limit = nil, precision = nil, scale = nil)
|
9
|
-
if native = native_database_types[type]
|
10
|
-
column_type_sql = (native.is_a?(Hash) ? native[:name] : native).dup
|
11
|
-
|
12
|
-
if type == :decimal # ignore limit, use precision and scale
|
13
|
-
scale ||= native[:scale]
|
14
|
-
|
15
|
-
if precision ||= native[:precision]
|
16
|
-
if scale
|
17
|
-
column_type_sql << "(#{precision},#{scale})"
|
18
|
-
else
|
19
|
-
column_type_sql << "(#{precision})"
|
20
|
-
end
|
21
|
-
elsif scale
|
22
|
-
raise ArgumentError, "Error adding decimal column: precision cannot be empty if scale if specified"
|
23
|
-
end
|
24
|
-
|
25
|
-
elsif limit ||= native.is_a?(Hash) && native[:limit]
|
26
|
-
column_type_sql << "(#{limit})"
|
27
|
-
end
|
28
|
-
|
29
|
-
column_type_sql
|
30
|
-
else
|
31
|
-
type
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
module ActiveRecord
|
40
|
-
module ConnectionAdapters
|
41
|
-
module CompatibilityMethods
|
42
|
-
def self.needed?(base)
|
43
|
-
!base.instance_methods.include?("quote_table_name")
|
44
|
-
end
|
45
|
-
|
46
|
-
def quote_table_name(name)
|
47
|
-
quote_column_name(name)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
data/lib/arjdbc/jdbc/core_ext.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
module ActiveRecord # :nodoc:
|
2
|
-
# Represents exceptions that have propagated up through the JDBC API.
|
3
|
-
class JDBCError < ActiveRecordError
|
4
|
-
# The vendor code or error number that came from the database
|
5
|
-
attr_accessor :errno
|
6
|
-
|
7
|
-
# The full Java SQLException object that was raised
|
8
|
-
attr_accessor :sql_exception
|
9
|
-
end
|
10
|
-
|
11
|
-
module ConnectionAdapters # :nodoc:
|
12
|
-
# Allows properly re-wrapping/re-defining methods that may already
|
13
|
-
# be alias_method_chain'd.
|
14
|
-
module ShadowCoreMethods
|
15
|
-
def alias_chained_method(meth, feature, target)
|
16
|
-
if instance_methods.include?("#{meth}_without_#{feature}")
|
17
|
-
alias_method "#{meth}_without_#{feature}".to_sym, target
|
18
|
-
else
|
19
|
-
alias_method meth, target if meth != target
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
data/lib/arjdbc/jdbc/discover.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
module ArJdbc
|
2
|
-
def self.discover_extensions
|
3
|
-
if defined?(::Gem)
|
4
|
-
files = Gem.find_files('arjdbc/discover')
|
5
|
-
else
|
6
|
-
files = $LOAD_PATH.map do |p|
|
7
|
-
discover = File.join(p, 'arjdbc','discover.rb')
|
8
|
-
File.exist?(p) ? discover : nil
|
9
|
-
end.compact
|
10
|
-
end
|
11
|
-
files.each do |f|
|
12
|
-
puts "Loading #{f}" if $DEBUG
|
13
|
-
require f
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
discover_extensions
|
18
|
-
end
|
data/lib/arjdbc/jdbc/driver.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
module ConnectionAdapters
|
3
|
-
class JdbcDriver
|
4
|
-
def initialize(name)
|
5
|
-
@name = name
|
6
|
-
end
|
7
|
-
|
8
|
-
def driver_class
|
9
|
-
@driver_class ||= begin
|
10
|
-
driver_class_const = (@name[0...1].capitalize + @name[1..@name.length]).gsub(/\./, '_')
|
11
|
-
Jdbc::Mutex.synchronized do
|
12
|
-
unless Jdbc.const_defined?(driver_class_const)
|
13
|
-
driver_class_name = @name
|
14
|
-
Jdbc.module_eval do
|
15
|
-
include_class(driver_class_name) { driver_class_const }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
driver_class = Jdbc.const_get(driver_class_const)
|
20
|
-
raise "You specify a driver for your JDBC connection" unless driver_class
|
21
|
-
driver_class
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def load
|
26
|
-
Jdbc::DriverManager.registerDriver(create)
|
27
|
-
end
|
28
|
-
|
29
|
-
def connection(url, user, pass)
|
30
|
-
Jdbc::DriverManager.getConnection(url, user, pass)
|
31
|
-
rescue
|
32
|
-
# bypass DriverManager to get around problem with dynamically loaded jdbc drivers
|
33
|
-
props = java.util.Properties.new
|
34
|
-
props.setProperty("user", user)
|
35
|
-
props.setProperty("password", pass)
|
36
|
-
create.connect(url, props)
|
37
|
-
end
|
38
|
-
|
39
|
-
def create
|
40
|
-
driver_class.new
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|