activerecord-jdbc-adapter 1.3.0.beta2 → 1.3.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +14 -8
- data/.travis.yml +40 -31
- data/.yardopts +4 -0
- data/Appraisals +2 -5
- data/CONTRIBUTING.md +46 -0
- data/Gemfile +21 -4
- data/Gemfile.lock +42 -17
- data/{History.txt → History.md} +142 -75
- data/README.md +102 -104
- data/RUNNING_TESTS.md +76 -0
- data/Rakefile.jdbc +20 -0
- data/activerecord-jdbc-adapter.gemspec +35 -18
- data/gemfiles/rails23.gemfile +4 -3
- data/gemfiles/rails23.gemfile.lock +9 -6
- data/gemfiles/rails30.gemfile +4 -3
- data/gemfiles/rails30.gemfile.lock +9 -6
- data/gemfiles/rails31.gemfile +4 -3
- data/gemfiles/rails31.gemfile.lock +9 -6
- data/gemfiles/rails32.gemfile +4 -3
- data/gemfiles/rails32.gemfile.lock +17 -14
- data/gemfiles/rails40.gemfile +5 -5
- data/gemfiles/rails40.gemfile.lock +17 -69
- data/lib/active_record/connection_adapters/firebird_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +1 -0
- data/lib/arel/visitors/compat.rb +22 -3
- data/lib/arel/visitors/db2.rb +8 -4
- data/lib/arel/visitors/derby.rb +14 -13
- data/lib/arel/visitors/firebird.rb +5 -4
- data/lib/arel/visitors/hsqldb.rb +11 -9
- data/lib/arel/visitors/sql_server.rb +89 -61
- data/lib/arjdbc.rb +1 -1
- data/lib/arjdbc/db2/adapter.rb +181 -212
- data/lib/arjdbc/db2/as400.rb +31 -18
- data/lib/arjdbc/db2/column.rb +167 -0
- data/lib/arjdbc/db2/connection_methods.rb +2 -0
- data/lib/arjdbc/derby/adapter.rb +206 -107
- data/lib/arjdbc/derby/connection_methods.rb +4 -9
- data/lib/arjdbc/firebird.rb +1 -0
- data/lib/arjdbc/firebird/adapter.rb +202 -64
- data/lib/arjdbc/firebird/connection_methods.rb +20 -0
- data/lib/arjdbc/h2/adapter.rb +56 -36
- data/lib/arjdbc/hsqldb/adapter.rb +99 -68
- data/lib/arjdbc/jdbc/adapter.rb +474 -265
- data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
- data/lib/arjdbc/jdbc/adapter_require.rb +8 -7
- data/lib/arjdbc/jdbc/arel_support.rb +132 -0
- data/lib/arjdbc/jdbc/base_ext.rb +8 -7
- data/lib/arjdbc/jdbc/callbacks.rb +16 -10
- data/lib/arjdbc/jdbc/column.rb +25 -3
- data/lib/arjdbc/jdbc/connection.rb +28 -55
- data/lib/arjdbc/jdbc/extension.rb +14 -14
- data/lib/arjdbc/jdbc/java.rb +6 -3
- data/lib/arjdbc/jdbc/jdbc.rake +1 -1
- data/lib/arjdbc/jdbc/quoted_primary_key.rb +2 -2
- data/lib/arjdbc/jdbc/rake_tasks.rb +1 -1
- data/lib/arjdbc/jdbc/type_converter.rb +5 -2
- data/lib/arjdbc/mssql/adapter.rb +160 -280
- data/lib/arjdbc/mssql/column.rb +182 -0
- data/lib/arjdbc/mssql/connection_methods.rb +37 -4
- data/lib/arjdbc/mssql/explain_support.rb +13 -21
- data/lib/arjdbc/mssql/limit_helpers.rb +79 -42
- data/lib/arjdbc/mssql/lock_methods.rb +77 -0
- data/lib/arjdbc/mssql/utils.rb +11 -11
- data/lib/arjdbc/mysql/adapter.rb +165 -247
- data/lib/arjdbc/mysql/column.rb +123 -0
- data/lib/arjdbc/mysql/connection_methods.rb +3 -6
- data/lib/arjdbc/oracle/adapter.rb +282 -288
- data/lib/arjdbc/oracle/column.rb +122 -0
- data/lib/arjdbc/oracle/connection_methods.rb +3 -0
- data/lib/arjdbc/postgresql/adapter.rb +336 -574
- data/lib/arjdbc/postgresql/column.rb +458 -0
- data/lib/arjdbc/postgresql/connection_methods.rb +1 -2
- data/lib/arjdbc/postgresql/schema_creation.rb +38 -0
- data/lib/arjdbc/sqlite3/adapter.rb +189 -145
- data/lib/arjdbc/sqlite3/explain_support.rb +1 -1
- data/lib/arjdbc/tasks/oracle/enhanced_structure_dump.rb +8 -8
- data/lib/arjdbc/util/quoted_cache.rb +60 -0
- data/lib/arjdbc/util/table_copier.rb +110 -0
- data/lib/arjdbc/version.rb +6 -7
- data/pom.xml +56 -2
- data/rakelib/02-test.rake +72 -83
- data/rakelib/db.rake +29 -17
- data/src/java/arjdbc/ArJdbcModule.java +21 -18
- data/src/java/arjdbc/db2/DB2RubyJdbcConnection.java +84 -12
- data/src/java/arjdbc/derby/DerbyModule.java +140 -143
- data/src/java/arjdbc/derby/DerbyRubyJdbcConnection.java +58 -7
- data/src/java/arjdbc/h2/H2Module.java +43 -0
- data/src/java/arjdbc/informix/InformixRubyJdbcConnection.java +7 -6
- data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +1223 -648
- data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +24 -23
- data/src/java/arjdbc/mysql/MySQLModule.java +33 -32
- data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +147 -30
- data/src/java/arjdbc/oracle/OracleModule.java +13 -13
- data/src/java/arjdbc/oracle/OracleRubyJdbcConnection.java +114 -6
- data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +166 -36
- data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +101 -19
- data/src/java/arjdbc/util/QuotingUtils.java +19 -19
- metadata +240 -394
- data/bench/bench_attributes.rb +0 -13
- data/bench/bench_attributes_new.rb +0 -14
- data/bench/bench_create.rb +0 -12
- data/bench/bench_find_all.rb +0 -12
- data/bench/bench_find_all_mt.rb +0 -25
- data/bench/bench_model.rb +0 -85
- data/bench/bench_new.rb +0 -12
- data/bench/bench_new_valid.rb +0 -12
- data/bench/bench_valid.rb +0 -13
- 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/arjdbc/jdbc/missing_functionality_helper.rb +0 -98
- data/lib/arjdbc/mssql/lock_helpers.rb +0 -76
- data/lib/arjdbc/mssql/tsql_methods.rb +0 -58
- data/lib/arjdbc/postgresql/column_cast.rb +0 -134
- data/test/activerecord/connections/native_jdbc_mysql/connection.rb +0 -25
- data/test/activerecord/jall.sh +0 -7
- data/test/activerecord/jtest.sh +0 -3
- data/test/assets/flowers.jpg +0 -0
- data/test/binary.rb +0 -67
- data/test/db/db2.rb +0 -43
- data/test/db/db2/binary_test.rb +0 -6
- data/test/db/db2/has_many_through_test.rb +0 -6
- data/test/db/db2/rake_test.rb +0 -82
- data/test/db/db2/rake_test_data.sql +0 -35
- data/test/db/db2/reset_column_information_test.rb +0 -5
- data/test/db/db2/serialize_test.rb +0 -6
- data/test/db/db2/simple_test.rb +0 -81
- data/test/db/db2/test_helper.rb +0 -6
- data/test/db/db2/unit_test.rb +0 -73
- data/test/db/derby.rb +0 -12
- data/test/db/derby/binary_test.rb +0 -6
- data/test/db/derby/migration_test.rb +0 -74
- data/test/db/derby/rake_test.rb +0 -96
- data/test/db/derby/reset_column_information_test.rb +0 -6
- data/test/db/derby/row_locking_test.rb +0 -20
- data/test/db/derby/schema_dump_test.rb +0 -5
- data/test/db/derby/serialize_test.rb +0 -6
- data/test/db/derby/simple_test.rb +0 -173
- data/test/db/derby/test_helper.rb +0 -6
- data/test/db/derby/unit_test.rb +0 -32
- data/test/db/derby/xml_column_test.rb +0 -17
- data/test/db/h2.rb +0 -11
- data/test/db/h2/binary_test.rb +0 -6
- data/test/db/h2/change_column_test.rb +0 -68
- data/test/db/h2/identity_column_test.rb +0 -35
- data/test/db/h2/offset_test.rb +0 -49
- data/test/db/h2/rake_test.rb +0 -98
- data/test/db/h2/schema_dump_test.rb +0 -29
- data/test/db/h2/serialize_test.rb +0 -6
- data/test/db/h2/simple_test.rb +0 -56
- data/test/db/hsqldb.rb +0 -11
- data/test/db/hsqldb/binary_test.rb +0 -6
- data/test/db/hsqldb/rake_test.rb +0 -101
- data/test/db/hsqldb/schema_dump_test.rb +0 -19
- data/test/db/hsqldb/serialize_test.rb +0 -6
- data/test/db/hsqldb/simple_test.rb +0 -17
- data/test/db/informix.rb +0 -13
- data/test/db/jdbc.rb +0 -16
- data/test/db/jdbc_derby.rb +0 -14
- data/test/db/jdbc_h2.rb +0 -17
- data/test/db/jdbc_mysql.rb +0 -13
- data/test/db/jdbc_postgres.rb +0 -23
- data/test/db/jndi_config.rb +0 -32
- data/test/db/jndi_pooled_config.rb +0 -32
- data/test/db/mssql.rb +0 -11
- data/test/db/mssql/binary_test.rb +0 -6
- data/test/db/mssql/exec_proc_test.rb +0 -46
- data/test/db/mssql/identity_insert_test.rb +0 -18
- data/test/db/mssql/ignore_system_views_test.rb +0 -40
- data/test/db/mssql/limit_offset_test.rb +0 -190
- data/test/db/mssql/multibyte_test.rb +0 -16
- data/test/db/mssql/multiple_connections_test.rb +0 -71
- data/test/db/mssql/rake_test.rb +0 -143
- data/test/db/mssql/reset_column_information_test.rb +0 -6
- data/test/db/mssql/row_locking_test.rb +0 -7
- data/test/db/mssql/serialize_test.rb +0 -6
- data/test/db/mssql/simple_test.rb +0 -140
- data/test/db/mssql/transaction_test.rb +0 -6
- data/test/db/mssql/types_test.rb +0 -205
- data/test/db/mssql/unit_test.rb +0 -249
- data/test/db/mysql.rb +0 -4
- data/test/db/mysql/_rails_test_mysql.32.out +0 -6585
- data/test/db/mysql/binary_test.rb +0 -6
- data/test/db/mysql/connection_test.rb +0 -51
- data/test/db/mysql/index_length_test.rb +0 -58
- data/test/db/mysql/multibyte_test.rb +0 -10
- data/test/db/mysql/nonstandard_primary_key_test.rb +0 -39
- data/test/db/mysql/rake_test.rb +0 -97
- data/test/db/mysql/reset_column_information_test.rb +0 -6
- data/test/db/mysql/schema_dump_test.rb +0 -228
- data/test/db/mysql/serialize_test.rb +0 -6
- data/test/db/mysql/simple_test.rb +0 -187
- data/test/db/mysql/statement_escaping_test.rb +0 -46
- data/test/db/mysql/transaction_test.rb +0 -6
- data/test/db/mysql/types_test.rb +0 -30
- data/test/db/mysql/unit_test.rb +0 -93
- data/test/db/mysql_config.rb +0 -7
- data/test/db/oracle.rb +0 -27
- data/test/db/oracle/binary_test.rb +0 -6
- data/test/db/oracle/limit_test.rb +0 -24
- data/test/db/oracle/multibyte_test.rb +0 -22
- data/test/db/oracle/rake_test.rb +0 -100
- data/test/db/oracle/reset_column_information_test.rb +0 -6
- data/test/db/oracle/serialize_test.rb +0 -6
- data/test/db/oracle/simple_test.rb +0 -140
- data/test/db/oracle/specific_test.rb +0 -180
- data/test/db/oracle/transaction_test.rb +0 -31
- data/test/db/oracle/unit_test.rb +0 -31
- data/test/db/postgres.rb +0 -11
- data/test/db/postgres/_rails_test_postgres.32.out +0 -6405
- data/test/db/postgres/a_custom_primary_key_test.rb +0 -50
- data/test/db/postgres/active_schema_unit_test.rb +0 -68
- data/test/db/postgres/array_type_test.rb +0 -101
- data/test/db/postgres/binary_test.rb +0 -6
- data/test/db/postgres/connection_test.rb +0 -63
- data/test/db/postgres/data_types_test.rb +0 -703
- data/test/db/postgres/hstore_test.rb +0 -200
- data/test/db/postgres/information_schema_leak_test.rb +0 -30
- data/test/db/postgres/json_test.rb +0 -86
- data/test/db/postgres/ltree_test.rb +0 -51
- data/test/db/postgres/mixed_case_test.rb +0 -29
- data/test/db/postgres/native_types_test.rb +0 -124
- data/test/db/postgres/rake_test.rb +0 -117
- data/test/db/postgres/reserved_test.rb +0 -22
- data/test/db/postgres/reset_column_information_test.rb +0 -6
- data/test/db/postgres/row_locking_test.rb +0 -21
- data/test/db/postgres/schema_dump_test.rb +0 -95
- data/test/db/postgres/schema_test.rb +0 -115
- data/test/db/postgres/simple_test.rb +0 -260
- data/test/db/postgres/table_alias_length_test.rb +0 -16
- data/test/db/postgres/transaction_test.rb +0 -6
- data/test/db/postgres/unit_test.rb +0 -31
- data/test/db/postgres_config.rb +0 -10
- data/test/db/sqlite3.rb +0 -6
- data/test/db/sqlite3/_rails_test_sqlite3.32.out +0 -6274
- data/test/db/sqlite3/has_many_though_test.rb +0 -6
- data/test/db/sqlite3/rake_test.rb +0 -71
- data/test/db/sqlite3/reset_column_information_test.rb +0 -6
- data/test/db/sqlite3/schema_dump_test.rb +0 -6
- data/test/db/sqlite3/serialize_test.rb +0 -6
- data/test/db/sqlite3/simple_test.rb +0 -268
- data/test/db/sqlite3/transaction_test.rb +0 -32
- data/test/db/sqlite3/type_conversion_test.rb +0 -104
- data/test/has_many_through.rb +0 -61
- data/test/informix_simple_test.rb +0 -48
- data/test/jdbc/db2.rb +0 -36
- data/test/jdbc/oracle.rb +0 -34
- data/test/jdbc_column_test.rb +0 -23
- data/test/jdbc_common.rb +0 -16
- data/test/jdbc_connection_test.rb +0 -196
- data/test/jndi_callbacks_test.rb +0 -33
- data/test/jndi_test.rb +0 -55
- data/test/manualTestDatabase.rb +0 -191
- data/test/models/add_not_null_column_to_table.rb +0 -9
- data/test/models/auto_id.rb +0 -15
- data/test/models/binary.rb +0 -18
- data/test/models/custom_pk_name.rb +0 -15
- data/test/models/data_types.rb +0 -40
- data/test/models/entry.rb +0 -41
- data/test/models/mixed_case.rb +0 -22
- data/test/models/reserved_word.rb +0 -15
- data/test/models/rights_and_roles.rb +0 -57
- data/test/models/string_id.rb +0 -17
- data/test/models/thing.rb +0 -17
- data/test/models/topic.rb +0 -32
- data/test/models/validates_uniqueness_of_string.rb +0 -19
- data/test/rails/mysql.rb +0 -13
- data/test/rails/sqlite3/version.rb +0 -6
- data/test/rails_stub.rb +0 -31
- data/test/rake_test_support.rb +0 -298
- data/test/row_locking.rb +0 -102
- data/test/schema_dump.rb +0 -182
- data/test/serialize.rb +0 -275
- data/test/shared_helper.rb +0 -35
- data/test/simple.rb +0 -1317
- data/test/sybase_jtds_simple_test.rb +0 -28
- data/test/sybase_reset_column_information_test.rb +0 -6
- data/test/test_helper.rb +0 -304
- data/test/transaction.rb +0 -109
data/README.md
CHANGED
@@ -1,56 +1,49 @@
|
|
1
1
|
# ActiveRecord JDBC Adapter
|
2
2
|
|
3
|
-
ActiveRecord-JDBC-Adapter (AR-JDBC) is a database adapter for Rails'
|
4
|
-
*ActiveRecord* component that can be used with [JRuby][0]. It allows use of
|
3
|
+
ActiveRecord-JDBC-Adapter (AR-JDBC) is a database adapter for Rails'
|
4
|
+
*ActiveRecord* component that can be used with [JRuby][0]. It allows use of
|
5
5
|
virtually any JDBC-compliant database with your JRuby on Rails application.
|
6
6
|
|
7
|
-
AR-JDBC **1.2.x** officially supports ActiveRecord 3.x as well as 2.3
|
8
|
-
latest version is compatible
|
9
|
-
use the latest and greatest of JRubies) thus
|
7
|
+
AR-JDBC **1.2.x** officially supports `ActiveRecord` **3.x** as well as **2.3**,
|
8
|
+
it's latest version is compatible and requires JRuby **1.6.8+** (but as always we
|
9
|
+
recommend to use the latest and greatest of JRubies) thus Java **1.6** is needed.
|
10
10
|
|
11
|
-
**NOTE:** version **1.3.
|
12
|
-
|
13
|
-
|
14
|
-
from the 1.2 line (we no longer back-port fixes) and still require to perform a
|
15
|
-
few refactorings we advise users to point their *Gemfiles* to our master or use
|
16
|
-
pre-release versions of our gem(s) e.g. **1.3.0.beta2**.
|
11
|
+
**NOTE:** version **1.3.x** of AR-JDBC adapter strives to provide `ActiveRecord`
|
12
|
+
**4.x** compatibility (as well as still supporting **2.3** and **3.x**) from a
|
13
|
+
single code base. It's a recommended update for all AR-JDBC 1.2.x users.
|
17
14
|
|
18
|
-
|
19
|
-
[security vulnerability](http://cl.ly/code/0n381E353414) and has been yanked,
|
20
|
-
please update ASAP (to version >= 1.2.8) if you happen to still be using it !
|
21
|
-
Caused by a [regression](http://git.io/MDmiGQ) introduced in the 1.2.6 release,
|
22
|
-
which was still not completely been fixed in 1.2.7 and has been yanked as well.
|
15
|
+
[![Gem Version](https://badge.fury.io/rb/activerecord-jdbc-adapter.png)](http://badge.fury.io/rb/activerecord-jdbc-adapter)
|
23
16
|
|
24
17
|
## Databases
|
25
18
|
|
26
19
|
ActiveRecord-JDBC-Adapter provides full or nearly full support for:
|
27
|
-
**MySQL**, **PostgreSQL**, **SQLite3**, **Oracle**, **Microsoft SQL Server**,
|
20
|
+
**MySQL**, **PostgreSQL**, **SQLite3**, **Oracle**, **Microsoft SQL Server**,
|
28
21
|
**DB2**, **FireBird**, **Derby**, **HSQLDB**, **H2**, and **Informix**.
|
29
22
|
|
30
23
|
Other databases will require testing and likely a custom configuration module.
|
31
|
-
Please join the JRuby [mailing list][1] to help us discover support for more
|
24
|
+
Please join the JRuby [mailing list][1] to help us discover support for more
|
32
25
|
databases.
|
33
26
|
|
34
27
|
## Using ActiveRecord JDBC
|
35
28
|
|
36
29
|
### Inside Rails
|
37
30
|
|
38
|
-
To use
|
31
|
+
To use AR-JDBC with JRuby on Rails:
|
39
32
|
|
40
33
|
1. Choose the adapter you wish to gem install. The following pre-packaged
|
41
|
-
adapters are available
|
34
|
+
adapters are available:
|
42
35
|
|
43
|
-
- Base JDBC (`activerecord-jdbc-adapter`) - supports all available databases
|
44
|
-
JDBC, but requires you to download and manually setup
|
45
|
-
|
36
|
+
- Base JDBC (`activerecord-jdbc-adapter`) - supports all available databases
|
37
|
+
via JDBC, but requires you to download and manually setup a JDBC driver for
|
38
|
+
the database you're using
|
46
39
|
- MySQL (`activerecord-jdbcmysql-adapter`)
|
47
40
|
- PostgreSQL (`activerecord-jdbcpostgresql-adapter`)
|
48
41
|
- SQLite3 (`activerecord-jdbcsqlite3-adapter`)
|
49
42
|
- Derby (`activerecord-jdbcderby-adapter`)
|
50
43
|
- HSQLDB (`activerecord-jdbchsqldb-adapter`)
|
51
44
|
- H2 (`activerecord-jdbch2-adapter`)
|
52
|
-
- MSSQL (`activerecord-jdbcmssql-adapter`) -
|
53
|
-
|
45
|
+
- MSSQL (`activerecord-jdbcmssql-adapter`) - uses the OSS jTDS driver by default
|
46
|
+
which might have issues with the latest SQLServer (does not support SQL Azure)
|
54
47
|
|
55
48
|
2a. For Rails 3, if you're generating a new application, use the
|
56
49
|
following command to generate your application:
|
@@ -59,41 +52,41 @@ following command to generate your application:
|
|
59
52
|
|
60
53
|
2b. Otherwise, you might need to perform some extra configuration steps
|
61
54
|
to prepare your Rails application for JDBC.
|
62
|
-
|
55
|
+
|
63
56
|
If you're using Rails 3, you'll need to modify your *Gemfile* to use the
|
64
57
|
*activerecord-jdbc-adapter* gem under JRuby. Change your *Gemfile* to look
|
65
|
-
like the following (using
|
58
|
+
like the following (using MySQL as an example):
|
66
59
|
|
67
60
|
```ruby
|
68
|
-
gem '
|
61
|
+
gem 'mysql', platform: :ruby
|
69
62
|
|
70
63
|
platforms :jruby do
|
71
64
|
gem 'jruby-openssl'
|
72
|
-
gem 'activerecord-
|
65
|
+
gem 'activerecord-jdbcmysql-adapter'
|
73
66
|
end
|
74
67
|
```
|
75
68
|
|
76
|
-
If you're using Rails 2:
|
69
|
+
If you're using Rails 2.3:
|
77
70
|
|
78
71
|
jruby script/generate jdbc
|
79
72
|
|
80
|
-
3. Configure your *database.yml* in the normal Rails style
|
81
|
-
|
82
|
-
Legacy configuration: If you use one of the convenience
|
83
|
-
*activerecord-jdbcXXX-adapter* adapters, you can still put a 'jdbc'
|
84
|
-
prefix in front of the database adapter name e.g. :
|
73
|
+
3. Configure your *database.yml* in the normal Rails style:
|
85
74
|
|
86
75
|
```yml
|
87
76
|
development:
|
88
|
-
adapter:
|
77
|
+
adapter: mysql
|
89
78
|
username: blog
|
90
|
-
password:
|
79
|
+
password: 1234
|
91
80
|
host: localhost
|
92
|
-
database:
|
81
|
+
database: blog_development
|
93
82
|
```
|
94
83
|
|
95
|
-
|
96
|
-
|
84
|
+
**Legacy Configuration:** If you use one of the *activerecord-jdbcxxx-adapter*
|
85
|
+
gems, you can still put a 'jdbc' prefix in front of the database adapter name,
|
86
|
+
e.g. `adapter: jdbcmysql`.
|
87
|
+
|
88
|
+
For plain JDBC database configurations, you'll need to know the database driver
|
89
|
+
class and URL (do not forget to put the driver .jar(s) on the class-path) e.g.:
|
97
90
|
|
98
91
|
```yml
|
99
92
|
development:
|
@@ -101,33 +94,33 @@ development:
|
|
101
94
|
username: blog
|
102
95
|
password:
|
103
96
|
driver: com.mysql.jdbc.Driver
|
104
|
-
url: jdbc:mysql://localhost:3306/
|
97
|
+
url: jdbc:mysql://localhost:3306/blog_development
|
105
98
|
```
|
106
99
|
|
107
|
-
For JNDI data sources, you may simply specify the JNDI location as follows (the
|
108
|
-
correct adapter type will be automatically detected)
|
100
|
+
For JNDI data sources, you may simply specify the JNDI location as follows (the
|
101
|
+
correct adapter type will be automatically detected):
|
109
102
|
|
110
103
|
```yml
|
111
104
|
production:
|
112
105
|
adapter: jdbc
|
113
|
-
jndi: jdbc/
|
106
|
+
jndi: jdbc/PostgreDB
|
114
107
|
```
|
115
108
|
|
116
109
|
JDBC driver specific properties might be set if you use an URL to specify the DB
|
117
|
-
or using the *properties:* syntax (since AR-JDBC **1.2.6**)
|
110
|
+
or using the *properties:* syntax (available since AR-JDBC **1.2.6**):
|
118
111
|
|
119
112
|
```yml
|
120
113
|
production:
|
121
114
|
adapter: mysql
|
122
115
|
username: blog
|
123
116
|
password: blog
|
124
|
-
url: "jdbc:mysql://localhost:3306/
|
117
|
+
url: "jdbc:mysql://localhost:3306/blog?profileSQL=true"
|
125
118
|
properties: # specific to com.mysql.jdbc.Driver
|
126
119
|
socketTimeout: 60000
|
127
120
|
connectTimeout: 60000
|
128
121
|
```
|
129
122
|
|
130
|
-
If you're really old school you might want to use AR-JDBC with a DB2 on z/OS
|
123
|
+
If you're really old school you might want to use AR-JDBC with a DB2 on z/OS:
|
131
124
|
|
132
125
|
```yml
|
133
126
|
development:
|
@@ -144,34 +137,28 @@ development:
|
|
144
137
|
password: lion
|
145
138
|
```
|
146
139
|
|
147
|
-
If your SGBD isn't automatically discovered you can force dialect :
|
140
|
+
If your SGBD isn't automatically discovered you can force a dialect as well:
|
141
|
+
|
148
142
|
```yml
|
149
143
|
development:
|
150
144
|
[...]
|
151
145
|
dialect: as400 # For example
|
152
146
|
```
|
153
147
|
|
154
|
-
|
148
|
+
More information on (configuring) AR-JDBC might be found on our [wiki][5].
|
155
149
|
|
156
|
-
|
157
|
-
|
158
|
-
jruby -S gem install activerecord-jdbc-adapter
|
159
|
-
|
160
|
-
If you wish to use the adapter for a specific database, you can install it
|
161
|
-
directly and the driver gem (dependency) will be installed as well :
|
162
|
-
|
163
|
-
jruby -S gem install activerecord-jdbcderby-adapter
|
150
|
+
### Standalone with ActiveRecord
|
164
151
|
|
165
|
-
|
152
|
+
Once the setup is made (see below) you can establish a JDBC connection like this (e.g. for `activerecord-jdbcderby-adapter`):
|
166
153
|
|
167
154
|
```ruby
|
168
155
|
ActiveRecord::Base.establish_connection(
|
169
|
-
:
|
170
|
-
:
|
156
|
+
adapter: 'derby',
|
157
|
+
database: 'db/my-database'
|
171
158
|
)
|
172
159
|
```
|
173
160
|
|
174
|
-
or
|
161
|
+
or using (requires that you manually put the driver jar on the classpath):
|
175
162
|
|
176
163
|
```ruby
|
177
164
|
ActiveRecord::Base.establish_connection(
|
@@ -181,69 +168,79 @@ ActiveRecord::Base.establish_connection(
|
|
181
168
|
)
|
182
169
|
```
|
183
170
|
|
184
|
-
|
171
|
+
#### Using Bundler
|
185
172
|
|
186
|
-
|
173
|
+
Proceed as with Rails; specify the ActiveRecord gem in your Bundle along with
|
174
|
+
the chosen (JDBC) adapters this time sample *Gemfile* for MySQL:
|
187
175
|
|
188
|
-
|
176
|
+
```ruby
|
177
|
+
gem 'activerecord', '~> 3.2.13'
|
178
|
+
gem 'activerecord-jdbcmysql-adapter', :platform => :jruby
|
179
|
+
```
|
189
180
|
|
190
|
-
|
191
|
-
|
192
|
-
|
181
|
+
When you `require 'bundler/setup'` everything will be set up for you as expected.
|
182
|
+
|
183
|
+
You do not need to use the 'helper' *activerecord-jdbcxxx-adapter* gem we provide
|
184
|
+
but than should make sure an appropriate JDBC driver is available at runtime, in
|
185
|
+
that case simply setup your *Gemfile* as:
|
193
186
|
|
194
187
|
```ruby
|
195
|
-
gem 'activerecord
|
196
|
-
gem 'activerecord-
|
197
|
-
gem 'jdbc-mysql', :github => 'jruby/activerecord-jdbc-adapter'
|
188
|
+
gem 'activerecord', '~> 4.0.0'
|
189
|
+
gem 'activerecord-jdbc-adapter', '~> 1.3.0', platform: :jruby
|
198
190
|
```
|
199
191
|
|
200
|
-
|
192
|
+
#### Without Bundler
|
201
193
|
|
202
|
-
|
194
|
+
Install the needed gems with JRuby:
|
203
195
|
|
204
|
-
|
205
|
-
MySQL installed, you can simply type `jruby -S rake` to run the tests.
|
206
|
-
A database named *weblog_development* is needed beforehand with a
|
207
|
-
connection user of "blog" and an empty password. You alse need to grant
|
208
|
-
"blog" create privileges on 'test_rake_db_create.*'.
|
196
|
+
jruby -S gem install activerecord activerecord-jdbc-adapter
|
209
197
|
|
210
|
-
If you
|
211
|
-
|
212
|
-
*weblog_development* and a user named "blog" with an empty password.
|
213
|
-
You can control the host and port the tests will attempt to by setting
|
214
|
-
the environment variables `PGHOST` and `PGPORT`.
|
198
|
+
If you wish to use the adapter for a specific database, you can install it
|
199
|
+
directly and the (jdbc-) driver gem (dependency) will be installed as well:
|
215
200
|
|
216
|
-
|
201
|
+
jruby -S gem install activerecord-jdbcderby-adapter
|
217
202
|
|
218
|
-
|
203
|
+
Your program should include:
|
219
204
|
|
220
|
-
|
221
|
-
|
205
|
+
```ruby
|
206
|
+
require 'active_record'
|
207
|
+
require 'activerecord-jdbc-adapter' if defined? JRUBY_VERSION
|
208
|
+
# or in case you're using the pre-packaged adapter gem :
|
209
|
+
require 'activerecord-jdbcderby-adapter' if defined? JRUBY_VERSION
|
210
|
+
```
|
222
211
|
|
223
|
-
|
224
|
-
*mssql*, *sybase*, *oracle*, *db2*, *derby*, *h2* or *hssql*.
|
212
|
+
## Extending AR-JDBC
|
225
213
|
|
226
|
-
|
214
|
+
You can create your own extension to AR-JDBC for a JDBC-based database that core
|
215
|
+
AR-JDBC does not support. We've created an example project for the Intersystems
|
216
|
+
Cache database that you can examine as a template.
|
217
|
+
See the [cachedb-adapter project][4] for more information.
|
227
218
|
|
228
|
-
|
219
|
+
## Source
|
229
220
|
|
230
|
-
|
231
|
-
`rails:test` task. Be sure to specify a driver and a path to the AR's sources :
|
221
|
+
The source for activerecord-jdbc-adapter is available using git:
|
232
222
|
|
233
|
-
|
223
|
+
git clone git://github.com/jruby/activerecord-jdbc-adapter.git
|
234
224
|
|
235
|
-
|
225
|
+
Please note that the project manages multiple gems from a single repository,
|
226
|
+
if you're using *Bundler* >= 1.2 it should be able to locate all gemspecs from
|
227
|
+
the git repository. Sample *Gemfile* for running with (MySQL) master:
|
236
228
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
229
|
+
```ruby
|
230
|
+
gem 'activerecord-jdbc-adapter', :github => 'jruby/activerecord-jdbc-adapter'
|
231
|
+
gem 'activerecord-jdbcmysql-adapter', :github => 'jruby/activerecord-jdbc-adapter'
|
232
|
+
```
|
233
|
+
|
234
|
+
## Getting Involved
|
235
|
+
|
236
|
+
Please read our [CONTRIBUTING](CONTRIBUTING.md) & [RUNNING_TESTS](RUNNING_TESTS.md)
|
237
|
+
guides for starters. You can always help us by maintaining AR-JDBC's [wiki][5].
|
241
238
|
|
242
239
|
## Feedback
|
243
240
|
|
244
|
-
Please report bugs at our [issue tracker][3]. If you're not sure if
|
241
|
+
Please report bugs at our [issue tracker][3]. If you're not sure if
|
245
242
|
something's a bug, feel free to pre-report it on the [mailing lists][1] or
|
246
|
-
ask on the #JRuby IRC channel on http://freenode.net
|
243
|
+
ask on the #JRuby IRC channel on http://freenode.net/ (try [web-chat][6]).
|
247
244
|
|
248
245
|
## Authors
|
249
246
|
|
@@ -252,10 +249,10 @@ This project was written by Nick Sieger <nick@nicksieger.com> and Ola Bini
|
|
252
249
|
|
253
250
|
## License
|
254
251
|
|
255
|
-
ActiveRecord-JDBC-Adapter is released under the BSD/MIT license.
|
256
|
-
See
|
252
|
+
ActiveRecord-JDBC-Adapter is open-source released under the BSD/MIT license.
|
253
|
+
See [LICENSE.txt](LICENSE.txt) included with the distribution for details.
|
257
254
|
|
258
|
-
Open-source driver gems within AR-JDBC's sources are licensed under the same
|
255
|
+
Open-source driver gems within AR-JDBC's sources are licensed under the same
|
259
256
|
license the database's drivers are licensed. See each driver gem's LICENSE.txt.
|
260
257
|
|
261
258
|
[0]: http://www.jruby.org/
|
@@ -263,4 +260,5 @@ license the database's drivers are licensed. See each driver gem's LICENSE.txt.
|
|
263
260
|
[2]: http://github.com/jruby/activerecord-jdbc-adapter/blob/master/activerecord-jdbcmssql-adapter
|
264
261
|
[3]: https://github.com/jruby/activerecord-jdbc-adapter/issues
|
265
262
|
[4]: http://github.com/nicksieger/activerecord-cachedb-adapter
|
266
|
-
[
|
263
|
+
[5]: https://github.com/jruby/activerecord-jdbc-adapter/wiki
|
264
|
+
[6]: https://webchat.freenode.net/?channels=#jruby
|
data/RUNNING_TESTS.md
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
|
2
|
+
## Running AR-JDBC's Tests
|
3
|
+
|
4
|
+
Most DB specific unit tests hide under the **test/db** directory, the files
|
5
|
+
included in the *test* directory are mostly shared test modules and helpers.
|
6
|
+
|
7
|
+
Rake tasks are loaded from **rakelib/02-test-rake**, most adapters have a
|
8
|
+
corresponding test_[adapter] task e.g. `rake test_sqlite3` that run against DB.
|
9
|
+
To check all available (test related) tasks simply `rake -T | grep test`.
|
10
|
+
|
11
|
+
If the adapter supports creating a database it will try to do so automatically
|
12
|
+
(most embed databases such as SQLite3) for some adapters (MySQL, PostgreSQL) we
|
13
|
+
do this auto-magically (see the `rake db:create` tasks), but otherwise you'll
|
14
|
+
need to setup a database dedicated for tests (using the standard tools that come
|
15
|
+
with your DB installation).
|
16
|
+
|
17
|
+
Connection parameters: database, host etc. can usually be changed from the shell
|
18
|
+
`env` for adapters where there might be no direct control over the DB
|
19
|
+
instance/configuration, e.g. for Oracle (by looking at **test/db/oracle.rb**)
|
20
|
+
one might adapt the test database configuration using :
|
21
|
+
```
|
22
|
+
export ORACLE_HOST=192.168.1.2
|
23
|
+
export ORACLE_USER=SAMPLE
|
24
|
+
export ORACLE_PASS=sample
|
25
|
+
export ORACLE_SID=MAIN
|
26
|
+
```
|
27
|
+
|
28
|
+
Tests are by default run against the "current" ActiveRecord version locked down
|
29
|
+
by Bundler, however since we usually do support more versions from a single code
|
30
|
+
base run those with the (appraisal) provided task e.g. for MySQL :
|
31
|
+
|
32
|
+
rake appraisal:rails31 test_mysql TEST=test/db/mysql/rake_test.rb
|
33
|
+
|
34
|
+
Observe the **TEST** variable used to specify a single file to be used to resolve
|
35
|
+
test cases, you pick tests by matching their names as well using **TESTOPTS** :
|
36
|
+
|
37
|
+
rake appraisal:rails40 test_postgres TESTOPTS="--name=/integer/"
|
38
|
+
|
39
|
+
This of course also works when running the "plain" test (no appraisal:xxx) task.
|
40
|
+
|
41
|
+
Since 1.3.0 we also support prepared statements, these are off by default (AR)
|
42
|
+
but one can easily run tests with prepared statements enabled using env vars :
|
43
|
+
|
44
|
+
rake test_derby PS=true # or PREPARED_STATEMENTS=true
|
45
|
+
|
46
|
+
|
47
|
+
### ActiveRecord (Rails) Tests
|
48
|
+
|
49
|
+
It's very desirable to pass all unit tests from ActiveRecord's own test suite.
|
50
|
+
Unfortunately it's been a while since we have accomplished that, luckily a lot
|
51
|
+
of failures are artificial (and would require tweaks at the Rails repo itself),
|
52
|
+
others simply need quality time spent to get them in shape and address issues.
|
53
|
+
|
54
|
+
First make sure you have the ActiveRecord (Rails) sources cloned locally :
|
55
|
+
|
56
|
+
git clone git://github.com/rails/rails.git
|
57
|
+
|
58
|
+
To run the AR-JDBC's sources agains AR tests, use the **rails:test** task, be
|
59
|
+
sure to specify a **DRIVER** and the **RAILS** sources path on the file system :
|
60
|
+
|
61
|
+
jruby -S rake rails:test DRIVER=derby RAILS=path/to/rails_source_dir
|
62
|
+
|
63
|
+
There's even tasks for Rails built-in adapters e.g. `rake rails:test_mysql`
|
64
|
+
|
65
|
+
You will likely only be able to run the Rails suite against the latest (stable)
|
66
|
+
ActiveRecord ~> version we support (check the *Gemfile.lock*) e.g. for
|
67
|
+
**activerecord (3.2.13)** you want to **git checkout 3-2-stable** branch.
|
68
|
+
|
69
|
+
We strive to not stub and include native (MRI) test required artefacts into
|
70
|
+
(non-test) code e.g. the `Mysql` module, instead put that into **test/rails**.
|
71
|
+
|
72
|
+
[![Build Status][0]](http://travis-ci.org/#!/jruby/activerecord-jdbc-adapter)
|
73
|
+
|
74
|
+
Happy Testing!
|
75
|
+
|
76
|
+
[0]: https://secure.travis-ci.org/jruby/activerecord-jdbc-adapter.png
|
data/Rakefile.jdbc
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# NOTE: shared Rakefile used for jdbc-xxx gems
|
2
|
+
|
3
|
+
require 'bundler/gem_helper'
|
4
|
+
|
5
|
+
name = Dir["*.gemspec"].first.sub('.gemspec', '')
|
6
|
+
gem_helper = Bundler::GemHelper.new(Dir.pwd, name)
|
7
|
+
def gem_helper.version_tag
|
8
|
+
"#{name}-#{version}" # override "v#{version}"
|
9
|
+
end
|
10
|
+
|
11
|
+
version = gem_helper.send(:version)
|
12
|
+
version_tag = gem_helper.version_tag
|
13
|
+
desc "Build #{name}-#{version}.gem into the pkg directory"
|
14
|
+
task('build') { gem_helper.build_gem }
|
15
|
+
|
16
|
+
desc "Build and install #{name}-#{version}.gem into system gems"
|
17
|
+
task('install') { gem_helper.install_gem }
|
18
|
+
|
19
|
+
desc "Create tag #{version_tag} build and push #{name}-#{version}.gem to Rubygems"
|
20
|
+
task('release') { gem_helper.release_gem }
|