activerecord-jdbc-adapter-onsite 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +22 -0
- data/.travis.yml +14 -0
- data/Appraisals +16 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +45 -0
- data/History.txt +488 -0
- data/LICENSE.txt +21 -0
- data/README.rdoc +214 -0
- data/Rakefile +62 -0
- data/activerecord-jdbc-adapter.gemspec +23 -0
- data/bench/bench_attributes.rb +13 -0
- data/bench/bench_attributes_new.rb +14 -0
- data/bench/bench_create.rb +12 -0
- data/bench/bench_find_all.rb +12 -0
- data/bench/bench_find_all_mt.rb +25 -0
- data/bench/bench_model.rb +85 -0
- data/bench/bench_new.rb +12 -0
- data/bench/bench_new_valid.rb +12 -0
- data/bench/bench_valid.rb +13 -0
- data/gemfiles/rails23.gemfile +10 -0
- data/gemfiles/rails23.gemfile.lock +38 -0
- data/gemfiles/rails30.gemfile +9 -0
- data/gemfiles/rails30.gemfile.lock +33 -0
- data/gemfiles/rails31.gemfile +9 -0
- data/gemfiles/rails31.gemfile.lock +35 -0
- data/gemfiles/rails32.gemfile +9 -0
- data/gemfiles/rails32.gemfile.lock +35 -0
- data/lib/active_record/connection_adapters/derby_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/h2_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/hsqldb_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/informix_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/jdbc_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/jndi_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/mssql_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/mysql_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/oracle_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +1 -0
- data/lib/activerecord-jdbc-adapter.rb +8 -0
- data/lib/arel/engines/sql/compilers/db2_compiler.rb +9 -0
- data/lib/arel/engines/sql/compilers/derby_compiler.rb +6 -0
- data/lib/arel/engines/sql/compilers/h2_compiler.rb +6 -0
- data/lib/arel/engines/sql/compilers/hsqldb_compiler.rb +15 -0
- data/lib/arel/engines/sql/compilers/jdbc_compiler.rb +6 -0
- data/lib/arel/engines/sql/compilers/mssql_compiler.rb +46 -0
- data/lib/arel/visitors/compat.rb +13 -0
- data/lib/arel/visitors/db2.rb +17 -0
- data/lib/arel/visitors/derby.rb +32 -0
- data/lib/arel/visitors/firebird.rb +24 -0
- data/lib/arel/visitors/hsqldb.rb +26 -0
- data/lib/arel/visitors/sql_server.rb +46 -0
- data/lib/arjdbc.rb +24 -0
- data/lib/arjdbc/db2.rb +2 -0
- data/lib/arjdbc/db2/adapter.rb +541 -0
- data/lib/arjdbc/derby.rb +7 -0
- data/lib/arjdbc/derby/adapter.rb +358 -0
- data/lib/arjdbc/derby/connection_methods.rb +19 -0
- data/lib/arjdbc/discover.rb +92 -0
- data/lib/arjdbc/firebird.rb +2 -0
- data/lib/arjdbc/firebird/adapter.rb +140 -0
- data/lib/arjdbc/h2.rb +4 -0
- data/lib/arjdbc/h2/adapter.rb +54 -0
- data/lib/arjdbc/h2/connection_methods.rb +13 -0
- data/lib/arjdbc/hsqldb.rb +4 -0
- data/lib/arjdbc/hsqldb/adapter.rb +184 -0
- data/lib/arjdbc/hsqldb/connection_methods.rb +15 -0
- data/lib/arjdbc/informix.rb +3 -0
- data/lib/arjdbc/informix/adapter.rb +142 -0
- data/lib/arjdbc/informix/connection_methods.rb +11 -0
- data/lib/arjdbc/jdbc.rb +2 -0
- data/lib/arjdbc/jdbc/adapter.rb +356 -0
- data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
- data/lib/arjdbc/jdbc/base_ext.rb +15 -0
- data/lib/arjdbc/jdbc/callbacks.rb +44 -0
- data/lib/arjdbc/jdbc/column.rb +47 -0
- data/lib/arjdbc/jdbc/compatibility.rb +51 -0
- data/lib/arjdbc/jdbc/connection.rb +134 -0
- data/lib/arjdbc/jdbc/connection_methods.rb +16 -0
- data/lib/arjdbc/jdbc/core_ext.rb +24 -0
- data/lib/arjdbc/jdbc/discover.rb +18 -0
- data/lib/arjdbc/jdbc/driver.rb +35 -0
- data/lib/arjdbc/jdbc/extension.rb +47 -0
- data/lib/arjdbc/jdbc/java.rb +14 -0
- data/lib/arjdbc/jdbc/jdbc.rake +131 -0
- data/lib/arjdbc/jdbc/missing_functionality_helper.rb +88 -0
- data/lib/arjdbc/jdbc/quoted_primary_key.rb +28 -0
- data/lib/arjdbc/jdbc/railtie.rb +9 -0
- data/lib/arjdbc/jdbc/rake_tasks.rb +10 -0
- data/lib/arjdbc/jdbc/require_driver.rb +16 -0
- data/lib/arjdbc/jdbc/type_converter.rb +126 -0
- data/lib/arjdbc/mimer.rb +2 -0
- data/lib/arjdbc/mimer/adapter.rb +142 -0
- data/lib/arjdbc/mssql.rb +4 -0
- data/lib/arjdbc/mssql/adapter.rb +477 -0
- data/lib/arjdbc/mssql/connection_methods.rb +31 -0
- data/lib/arjdbc/mssql/limit_helpers.rb +101 -0
- data/lib/arjdbc/mssql/lock_helpers.rb +72 -0
- data/lib/arjdbc/mssql/tsql_helper.rb +61 -0
- data/lib/arjdbc/mysql.rb +4 -0
- data/lib/arjdbc/mysql/adapter.rb +505 -0
- data/lib/arjdbc/mysql/connection_methods.rb +28 -0
- data/lib/arjdbc/oracle.rb +3 -0
- data/lib/arjdbc/oracle/adapter.rb +432 -0
- data/lib/arjdbc/oracle/connection_methods.rb +12 -0
- data/lib/arjdbc/postgresql.rb +4 -0
- data/lib/arjdbc/postgresql/adapter.rb +861 -0
- data/lib/arjdbc/postgresql/connection_methods.rb +23 -0
- data/lib/arjdbc/sqlite3.rb +4 -0
- data/lib/arjdbc/sqlite3/adapter.rb +389 -0
- data/lib/arjdbc/sqlite3/connection_methods.rb +35 -0
- data/lib/arjdbc/sybase.rb +2 -0
- data/lib/arjdbc/sybase/adapter.rb +46 -0
- data/lib/arjdbc/version.rb +8 -0
- data/lib/generators/jdbc/USAGE +10 -0
- data/lib/generators/jdbc/jdbc_generator.rb +9 -0
- data/lib/jdbc_adapter.rb +2 -0
- data/lib/jdbc_adapter/rake_tasks.rb +3 -0
- data/lib/jdbc_adapter/version.rb +3 -0
- data/lib/pg.rb +26 -0
- data/pom.xml +57 -0
- data/rails_generators/jdbc_generator.rb +15 -0
- data/rails_generators/templates/config/initializers/jdbc.rb +7 -0
- data/rails_generators/templates/lib/tasks/jdbc.rake +8 -0
- data/rakelib/bundler_ext.rb +11 -0
- data/rakelib/compile.rake +23 -0
- data/rakelib/db.rake +39 -0
- data/rakelib/rails.rake +41 -0
- data/src/java/arjdbc/db2/DB2RubyJdbcConnection.java +69 -0
- data/src/java/arjdbc/derby/DerbyModule.java +324 -0
- data/src/java/arjdbc/h2/H2RubyJdbcConnection.java +70 -0
- data/src/java/arjdbc/informix/InformixRubyJdbcConnection.java +74 -0
- data/src/java/arjdbc/jdbc/AdapterJavaService.java +68 -0
- data/src/java/arjdbc/jdbc/JdbcConnectionFactory.java +36 -0
- data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +1346 -0
- data/src/java/arjdbc/jdbc/SQLBlock.java +48 -0
- data/src/java/arjdbc/mssql/MssqlRubyJdbcConnection.java +127 -0
- data/src/java/arjdbc/mysql/MySQLModule.java +134 -0
- data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +161 -0
- data/src/java/arjdbc/oracle/OracleRubyJdbcConnection.java +85 -0
- data/src/java/arjdbc/postgresql/PostgresqlRubyJdbcConnection.java +82 -0
- data/src/java/arjdbc/sqlite3/Sqlite3RubyJdbcConnection.java +126 -0
- data/test/abstract_db_create.rb +135 -0
- data/test/activerecord/connection_adapters/type_conversion_test.rb +31 -0
- data/test/activerecord/connections/native_jdbc_mysql/connection.rb +25 -0
- data/test/activerecord/jall.sh +7 -0
- data/test/activerecord/jtest.sh +3 -0
- data/test/db/db2.rb +11 -0
- data/test/db/derby.rb +12 -0
- data/test/db/h2.rb +11 -0
- data/test/db/hsqldb.rb +13 -0
- data/test/db/informix.rb +11 -0
- data/test/db/jdbc.rb +12 -0
- data/test/db/jndi_config.rb +40 -0
- data/test/db/logger.rb +3 -0
- data/test/db/mssql.rb +9 -0
- data/test/db/mysql.rb +10 -0
- data/test/db/oracle.rb +34 -0
- data/test/db/postgres.rb +18 -0
- data/test/db/sqlite3.rb +11 -0
- data/test/db2_reset_column_information_test.rb +8 -0
- data/test/db2_simple_test.rb +66 -0
- data/test/derby_migration_test.rb +68 -0
- data/test/derby_multibyte_test.rb +12 -0
- data/test/derby_reset_column_information_test.rb +8 -0
- data/test/derby_row_locking_test.rb +9 -0
- data/test/derby_simple_test.rb +139 -0
- data/test/generic_jdbc_connection_test.rb +29 -0
- data/test/h2_change_column_test.rb +68 -0
- data/test/h2_simple_test.rb +41 -0
- data/test/has_many_through.rb +79 -0
- data/test/helper.rb +108 -0
- data/test/hsqldb_simple_test.rb +6 -0
- data/test/informix_simple_test.rb +48 -0
- data/test/jdbc_common.rb +28 -0
- data/test/jndi_callbacks_test.rb +36 -0
- data/test/jndi_test.rb +25 -0
- data/test/manualTestDatabase.rb +191 -0
- data/test/models/add_not_null_column_to_table.rb +9 -0
- data/test/models/auto_id.rb +15 -0
- data/test/models/custom_pk_name.rb +14 -0
- data/test/models/data_types.rb +30 -0
- data/test/models/entry.rb +40 -0
- data/test/models/mixed_case.rb +22 -0
- data/test/models/reserved_word.rb +15 -0
- data/test/models/string_id.rb +17 -0
- data/test/models/thing.rb +16 -0
- data/test/models/validates_uniqueness_of_string.rb +19 -0
- data/test/mssql_db_create_test.rb +26 -0
- data/test/mssql_identity_insert_test.rb +19 -0
- data/test/mssql_ignore_system_views_test.rb +27 -0
- data/test/mssql_legacy_types_test.rb +58 -0
- data/test/mssql_limit_offset_test.rb +136 -0
- data/test/mssql_multibyte_test.rb +18 -0
- data/test/mssql_null_test.rb +14 -0
- data/test/mssql_reset_column_information_test.rb +8 -0
- data/test/mssql_row_locking_sql_test.rb +159 -0
- data/test/mssql_row_locking_test.rb +9 -0
- data/test/mssql_simple_test.rb +55 -0
- data/test/mysql_db_create_test.rb +27 -0
- data/test/mysql_index_length_test.rb +58 -0
- data/test/mysql_info_test.rb +123 -0
- data/test/mysql_multibyte_test.rb +10 -0
- data/test/mysql_nonstandard_primary_key_test.rb +42 -0
- data/test/mysql_reset_column_information_test.rb +8 -0
- data/test/mysql_simple_test.rb +125 -0
- data/test/oracle_reset_column_information_test.rb +8 -0
- data/test/oracle_simple_test.rb +18 -0
- data/test/oracle_specific_test.rb +83 -0
- data/test/postgres_db_create_test.rb +32 -0
- data/test/postgres_drop_db_test.rb +16 -0
- data/test/postgres_information_schema_leak_test.rb +29 -0
- data/test/postgres_mixed_case_test.rb +29 -0
- data/test/postgres_native_type_mapping_test.rb +93 -0
- data/test/postgres_nonseq_pkey_test.rb +38 -0
- data/test/postgres_reserved_test.rb +22 -0
- data/test/postgres_reset_column_information_test.rb +8 -0
- data/test/postgres_schema_search_path_test.rb +48 -0
- data/test/postgres_simple_test.rb +168 -0
- data/test/postgres_table_alias_length_test.rb +15 -0
- data/test/postgres_type_conversion_test.rb +34 -0
- data/test/row_locking.rb +90 -0
- data/test/simple.rb +731 -0
- data/test/sqlite3_reset_column_information_test.rb +8 -0
- data/test/sqlite3_simple_test.rb +316 -0
- data/test/sybase_jtds_simple_test.rb +28 -0
- data/test/sybase_reset_column_information_test.rb +8 -0
- metadata +288 -0
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Copyright (c) 2006-2008 Nick Sieger <nick@nicksieger.com>
|
|
2
|
+
Copyright (c) 2006-2008 Ola Bini <ola.bini@gmail.com>
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
5
|
+
a copy of this software and associated documentation files (the
|
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
10
|
+
the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be
|
|
13
|
+
included in all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
= Activerecord-jdbc-adapter
|
|
2
|
+
|
|
3
|
+
activerecord-jdbc-adapter is a database adapter for Rails' ActiveRecord
|
|
4
|
+
component that can be used with JRuby[http://www.jruby.org/]. It allows use of
|
|
5
|
+
virtually any JDBC-compliant database with your JRuby on Rails application.
|
|
6
|
+
|
|
7
|
+
== Databases
|
|
8
|
+
|
|
9
|
+
Activerecord-jdbc-adapter provides full or nearly full support for:
|
|
10
|
+
MySQL, PostgreSQL, SQLite3, Oracle, Microsoft SQL Server, DB2,
|
|
11
|
+
FireBird, Derby, HSQLDB, H2, and Informix.
|
|
12
|
+
|
|
13
|
+
Other databases will require testing and likely a custom configuration module.
|
|
14
|
+
Please join the JRuby {mailing list}[http://jruby.org/community] to help us
|
|
15
|
+
discover support for more databases.
|
|
16
|
+
|
|
17
|
+
== Using ActiveRecord JDBC
|
|
18
|
+
|
|
19
|
+
=== Inside Rails
|
|
20
|
+
|
|
21
|
+
To use activerecord-jdbc-adapter with JRuby on Rails:
|
|
22
|
+
|
|
23
|
+
1. Choose the adapter you wish to gem install. The following pre-packaged
|
|
24
|
+
adapters are available:
|
|
25
|
+
|
|
26
|
+
- base jdbc (activerecord-jdbc-adapter). Supports all available databases via
|
|
27
|
+
JDBC, but requires you to download and manually install the database vendor's
|
|
28
|
+
JDBC driver .jar file.
|
|
29
|
+
- mysql (activerecord-jdbcmysql-adapter)
|
|
30
|
+
- postgresql (activerecord-jdbcpostgresql-adapter)
|
|
31
|
+
- sqlite3 (activerecord-jdbcsqlite3-adapter)
|
|
32
|
+
- derby (activerecord-jdbcderby-adapter)
|
|
33
|
+
- hsqldb (activerecord-jdbchsqldb-adapter)
|
|
34
|
+
- h2 (activerecord-jdbch2-adapter)
|
|
35
|
+
- mssql (activerecord-jdbcmssql-adapter). Does not support SQL Azure by default,
|
|
36
|
+
see the {project's readme}[https://github.com/jruby/activerecord-jdbc-adapter/blob/master/activerecord-jdbcmssql-adapter/README.rdoc]
|
|
37
|
+
for more information.
|
|
38
|
+
|
|
39
|
+
2a. For Rails 3, if you're generating a new application, use the
|
|
40
|
+
following command to generate your application:
|
|
41
|
+
|
|
42
|
+
jruby -S rails new sweetapp
|
|
43
|
+
|
|
44
|
+
2b. Otherwise, you'll need to perform some extra configuration steps
|
|
45
|
+
to prepare your Rails application for JDBC.
|
|
46
|
+
|
|
47
|
+
If you're using Rails 3, you'll need to modify your Gemfile to use the
|
|
48
|
+
activerecord-jdbc-adapter gem under JRuby. Change your Gemfile to look
|
|
49
|
+
like the following (using sqlite3 as an example):
|
|
50
|
+
|
|
51
|
+
platforms :ruby do
|
|
52
|
+
gem 'sqlite3'
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
platforms :jruby do
|
|
56
|
+
gem 'jruby-openssl'
|
|
57
|
+
gem 'activerecord-jdbcsqlite3-adapter'
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
If you're using Rails 2:
|
|
61
|
+
|
|
62
|
+
jruby script/generate jdbc
|
|
63
|
+
|
|
64
|
+
3. Configure your database.yml in the normal Rails style.
|
|
65
|
+
|
|
66
|
+
Legacy configuration: If you use one of the convenience
|
|
67
|
+
'activerecord-jdbcXXX-adapter' adapters, you can still put a 'jdbc'
|
|
68
|
+
prefix in front of the database adapter name as below.
|
|
69
|
+
|
|
70
|
+
development:
|
|
71
|
+
adapter: jdbcmysql
|
|
72
|
+
username: blog
|
|
73
|
+
password:
|
|
74
|
+
host: localhost
|
|
75
|
+
database: weblog_development
|
|
76
|
+
|
|
77
|
+
For other databases, you'll need to know the database driver class and
|
|
78
|
+
URL. Example:
|
|
79
|
+
|
|
80
|
+
development:
|
|
81
|
+
adapter: jdbc
|
|
82
|
+
username: blog
|
|
83
|
+
password:
|
|
84
|
+
driver: com.mysql.jdbc.Driver
|
|
85
|
+
url: jdbc:mysql://localhost:3306/weblog_development
|
|
86
|
+
|
|
87
|
+
For JNDI data sources, you may simply specify the JNDI location as follows
|
|
88
|
+
(the adapter will be automatically detected):
|
|
89
|
+
|
|
90
|
+
production:
|
|
91
|
+
adapter: jdbc
|
|
92
|
+
jndi: jdbc/mysqldb
|
|
93
|
+
|
|
94
|
+
If you're really old school you might want to use ARJDBC with a DB2 on z/OS.
|
|
95
|
+
|
|
96
|
+
development:
|
|
97
|
+
adapter: jdbc
|
|
98
|
+
encoding: unicode
|
|
99
|
+
url: jdbc:db2j:net://mightyzoshost:446/RAILS_DBT1
|
|
100
|
+
driver: com.ibm.db2.jcc.DB2Driver
|
|
101
|
+
schema: DB2XB12
|
|
102
|
+
database: RAILS_DB1
|
|
103
|
+
tablespace: TSDE911
|
|
104
|
+
lob_tablespaces:
|
|
105
|
+
first_table: TSDE912
|
|
106
|
+
username: scott
|
|
107
|
+
password: lion
|
|
108
|
+
|
|
109
|
+
=== Standalone, with ActiveRecord
|
|
110
|
+
|
|
111
|
+
1. Install the gem with JRuby:
|
|
112
|
+
|
|
113
|
+
jruby -S gem install activerecord-jdbc-adapter
|
|
114
|
+
|
|
115
|
+
If you wish to use the adapter for a specific database, you can
|
|
116
|
+
install it directly and a driver gem will be installed as well:
|
|
117
|
+
|
|
118
|
+
jruby -S gem install activerecord-jdbcderby-adapter
|
|
119
|
+
|
|
120
|
+
2. After this you can establish a JDBC connection like this:
|
|
121
|
+
|
|
122
|
+
ActiveRecord::Base.establish_connection(
|
|
123
|
+
:adapter => 'jdbcderby',
|
|
124
|
+
:database => "db/my-database"
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
or like this (but requires that you manually put the driver jar on the classpath):
|
|
128
|
+
|
|
129
|
+
ActiveRecord::Base.establish_connection(
|
|
130
|
+
:adapter => 'jdbc',
|
|
131
|
+
:driver => 'org.apache.derby.jdbc.EmbeddedDriver',
|
|
132
|
+
:url => 'jdbc:derby:test_ar;create=true'
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
== Extending AR-JDBC
|
|
136
|
+
|
|
137
|
+
You can create your own extension to AR-JDBC for a JDBC-based database
|
|
138
|
+
that core AR-JDBC does not support. We've created an example project
|
|
139
|
+
for the Intersystems Cache database that you can examine as a
|
|
140
|
+
template. See the project for more information at the following URL:
|
|
141
|
+
|
|
142
|
+
http://github.com/nicksieger/activerecord-cachedb-adapter
|
|
143
|
+
|
|
144
|
+
== Getting the source
|
|
145
|
+
|
|
146
|
+
The source for activerecord-jdbc-adapter is available using git.
|
|
147
|
+
|
|
148
|
+
git clone git://github.com/jruby/activerecord-jdbc-adapter.git
|
|
149
|
+
|
|
150
|
+
== Feedback
|
|
151
|
+
|
|
152
|
+
Please file bug reports at
|
|
153
|
+
http://kenai.com/jira/browse/ACTIVERECORD_JDBC. If you're not sure if
|
|
154
|
+
something's a bug, feel free to pre-report it on the mailing lists.
|
|
155
|
+
|
|
156
|
+
== Project Info
|
|
157
|
+
|
|
158
|
+
* Mailing Lists: http://jruby.org/community
|
|
159
|
+
* Issues: https://github.com/jruby/activerecord-jdbc-adapter/issues
|
|
160
|
+
* Source: git://github.com/jruby/activerecord-jdbc-adapter.git
|
|
161
|
+
|
|
162
|
+
== Running AR-JDBC's Tests
|
|
163
|
+
|
|
164
|
+
Drivers for 6 open-source databases are included. Provided you have
|
|
165
|
+
MySQL installed, you can simply type <tt>jruby -S rake</tt> to run the
|
|
166
|
+
tests. A database named <tt>weblog_development</tt> is needed
|
|
167
|
+
beforehand with a connection user of "blog" and an empty password. You
|
|
168
|
+
alse need to grant "blog" create privileges on
|
|
169
|
+
'test_rake_db_create.*'.
|
|
170
|
+
|
|
171
|
+
If you also have PostgreSQL available, those tests will be run if the
|
|
172
|
+
`psql' executable can be found. Also ensure you have a database named
|
|
173
|
+
<tt>weblog_development</tt> and a user named "blog" and an empty
|
|
174
|
+
password. You can control the host and port the tests will attempt to
|
|
175
|
+
by setting the environment variables PGHOST and PGPORT.
|
|
176
|
+
|
|
177
|
+
If you want rails logging enabled during these test runs you can edit
|
|
178
|
+
test/jdbc_common.rb and add the following line:
|
|
179
|
+
|
|
180
|
+
require 'db/logger'
|
|
181
|
+
|
|
182
|
+
To execute a single test case, you can run:
|
|
183
|
+
|
|
184
|
+
rake appraisal:{version} test_{db} TEST=test/{tests file}
|
|
185
|
+
|
|
186
|
+
Substitute the version of ActiveRecord for version, which can be one of:
|
|
187
|
+
rails23, rails30, rails31, or rails32
|
|
188
|
+
The db can be one of these:
|
|
189
|
+
mssql, mysql, oracle, postgres, sybase, sqlite3, db2, derby, h2
|
|
190
|
+
Finally, the tests file will be whichever test case you want to run.
|
|
191
|
+
|
|
192
|
+
== Running AR Tests
|
|
193
|
+
|
|
194
|
+
To run the current AR-JDBC sources with ActiveRecord, just use the
|
|
195
|
+
included "rails:test" task. Be sure to specify a driver and a path to
|
|
196
|
+
the ActiveRecord sources.
|
|
197
|
+
|
|
198
|
+
jruby -S rake rails:test DRIVER=mysql RAILS=/path/activerecord_source_dir
|
|
199
|
+
|
|
200
|
+
== Travis Build Status {<img src="https://secure.travis-ci.org/jruby/activerecord-jdbc-adapter.png"/>}[http://travis-ci.org/#!/jruby/activerecord-jdbc-adapter]
|
|
201
|
+
|
|
202
|
+
== Authors
|
|
203
|
+
|
|
204
|
+
This project was written by Nick Sieger <nick@nicksieger.com> and Ola Bini
|
|
205
|
+
<olabini@gmail.com> with lots of help from the JRuby community.
|
|
206
|
+
|
|
207
|
+
== License
|
|
208
|
+
|
|
209
|
+
activerecord-jdbc-adapter is released under a BSD license. See the LICENSE file
|
|
210
|
+
included with the distribution for details.
|
|
211
|
+
|
|
212
|
+
Open-source driver gems for activerecord-jdbc-adapter are licensed under the
|
|
213
|
+
same license the database's drivers are licensed. See each driver gem's
|
|
214
|
+
LICENSE.txt file for details.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require 'rake/testtask'
|
|
2
|
+
require 'rake/clean'
|
|
3
|
+
CLEAN.include 'derby*', 'test.db.*','test/reports', 'test.sqlite3','lib/**/*.jar','manifest.mf', '*.log'
|
|
4
|
+
|
|
5
|
+
require 'bundler'
|
|
6
|
+
Bundler::GemHelper.install_tasks
|
|
7
|
+
require 'bundler/setup'
|
|
8
|
+
|
|
9
|
+
require 'appraisal'
|
|
10
|
+
|
|
11
|
+
require File.expand_path('../test/helper', __FILE__)
|
|
12
|
+
|
|
13
|
+
task :default => [:jar, :test]
|
|
14
|
+
|
|
15
|
+
#ugh, bundler doesn't use tasks, so gotta hook up to both tasks.
|
|
16
|
+
task :build => :jar
|
|
17
|
+
task :install => :jar
|
|
18
|
+
|
|
19
|
+
ADAPTERS = %w[derby h2 hsqldb mssql mysql postgresql sqlite3].map {|a| "activerecord-jdbc#{a}-adapter" }
|
|
20
|
+
DRIVERS = %w[derby h2 hsqldb jtds mysql postgres sqlite3].map {|a| "jdbc-#{a}" }
|
|
21
|
+
|
|
22
|
+
def rake(args)
|
|
23
|
+
ruby "-S", "rake", *args
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
(ADAPTERS + DRIVERS).each do |adapter|
|
|
27
|
+
namespace adapter do
|
|
28
|
+
|
|
29
|
+
task :build do
|
|
30
|
+
Dir.chdir(adapter) do
|
|
31
|
+
rake "build"
|
|
32
|
+
end
|
|
33
|
+
cp FileList["#{adapter}/pkg/#{adapter}-*.gem"], "pkg"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# bundler handles install => build itself
|
|
37
|
+
task :install do
|
|
38
|
+
Dir.chdir(adapter) do
|
|
39
|
+
rake "install"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
task :release do
|
|
44
|
+
Dir.chdir(adapter) do
|
|
45
|
+
rake "release"
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
desc "Release all adapters"
|
|
52
|
+
task "all:release" => ["release", *ADAPTERS.map { |f| "#{f}:release" }]
|
|
53
|
+
|
|
54
|
+
desc "Install all adapters"
|
|
55
|
+
task "all:install" => ["install", *ADAPTERS.map { |f| "#{f}:install" }]
|
|
56
|
+
|
|
57
|
+
desc "Build all adapters"
|
|
58
|
+
task "all:build" => ["build", *ADAPTERS.map { |f| "#{f}:build" }]
|
|
59
|
+
|
|
60
|
+
task :filelist do
|
|
61
|
+
puts FileList['pkg/**/*'].inspect
|
|
62
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require 'arjdbc/version'
|
|
4
|
+
version = ArJdbc::Version::VERSION
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "activerecord-jdbc-adapter-onsite"
|
|
7
|
+
s.version = version
|
|
8
|
+
s.platform = Gem::Platform::RUBY
|
|
9
|
+
s.authors = ["Nick Sieger, Ola Bini and JRuby contributors"]
|
|
10
|
+
s.email = %q{nick@nicksieger.com, ola.bini@gmail.com}
|
|
11
|
+
s.homepage = %q{https://github.com/jruby/activerecord-jdbc-adapter}
|
|
12
|
+
s.summary = %q{JDBC adapter for ActiveRecord, for use within JRuby on Rails.}
|
|
13
|
+
s.description = %q{activerecord-jdbc-adapter is a database adapter for Rails\' ActiveRecord
|
|
14
|
+
component that can be used with JRuby[http://www.jruby.org/]. It allows use of
|
|
15
|
+
virtually any JDBC-compliant database with your JRuby on Rails application.}
|
|
16
|
+
s.files = `git ls-files`.split("\n").reject {|v| v =~ /^(activerecord-jdbc[^-]|jdbc-)/}
|
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f) }
|
|
19
|
+
s.require_paths = ["lib"]
|
|
20
|
+
s.rdoc_options = ["--main", "README.rdoc", "-SHN", "-f", "darkfish"]
|
|
21
|
+
s.rubyforge_project = %q{jruby-extras}
|
|
22
|
+
end
|
|
23
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/bench_model'
|
|
2
|
+
|
|
3
|
+
puts "Widget.find(:first).attributes"
|
|
4
|
+
Benchmark.bm do |make|
|
|
5
|
+
TIMES.times do
|
|
6
|
+
w = Widget.find(:first)
|
|
7
|
+
make.report do
|
|
8
|
+
10_000.times do
|
|
9
|
+
w.attributes # rails makes copy for every call
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/bench_model'
|
|
2
|
+
|
|
3
|
+
puts "w = Widget.find(:first); Widget.new(w.attributes)"
|
|
4
|
+
Benchmark.bm do |make|
|
|
5
|
+
TIMES.times do
|
|
6
|
+
w = Widget.find(:first)
|
|
7
|
+
params = w.attributes
|
|
8
|
+
make.report do
|
|
9
|
+
10_000.times do
|
|
10
|
+
Widget.new(params)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/bench_model'
|
|
2
|
+
|
|
3
|
+
Benchmark.bm do |make|
|
|
4
|
+
TIMES.times do
|
|
5
|
+
make.report do
|
|
6
|
+
thrs = []
|
|
7
|
+
errs = 0
|
|
8
|
+
10.times do
|
|
9
|
+
thrs << Thread.new do
|
|
10
|
+
1000.times do
|
|
11
|
+
begin
|
|
12
|
+
Widget.find(:all)
|
|
13
|
+
rescue Exception => e
|
|
14
|
+
errs += 1
|
|
15
|
+
Widget.logger.warn e.to_s
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
Widget.clear_active_connections!
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
thrs.each {|t| t.join}
|
|
22
|
+
puts "errors: #{errs}" if errs > 0
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
* This scripts looks for an optional argv0 which is number of times to
|
|
4
|
+
execute the particular benchmark this file is getting required into. argv1
|
|
5
|
+
is an optional parameter which represents the number of rows to create.
|
|
6
|
+
* Use ENV['LOGGER'] (=severe|warn|info|debug) to turn on the logger
|
|
7
|
+
* Add ActiveRecord to load path to use a specific (non-gem version) for testing (e.g., edge).
|
|
8
|
+
|
|
9
|
+
+----------+------+-----+---------+-----------------+----------------+
|
|
10
|
+
| Field | Type | Null | Key | Default | Extra |
|
|
11
|
+
+-------------+--------------+------+-----+---------+----------------+
|
|
12
|
+
| id | int(11) | NO | PRI | NULL | auto_increment |
|
|
13
|
+
| name | varchar(255) | YES | | NULL | |
|
|
14
|
+
| description | text | YES | | NULL | |
|
|
15
|
+
| created_at | datetime | YES | | NULL | |
|
|
16
|
+
| updated_at | datetime | YES | | NULL | |
|
|
17
|
+
+-------------+--------------+------+-----+---------+----------------+
|
|
18
|
+
=end
|
|
19
|
+
|
|
20
|
+
TIMES = (ARGV[0] || 5).to_i
|
|
21
|
+
ROW_COUNT = (ARGV[1] || 10).to_i
|
|
22
|
+
|
|
23
|
+
ENV["RAILS_ENV"] = "production"
|
|
24
|
+
begin
|
|
25
|
+
print "Loading ActiveRecord w/o gems..."
|
|
26
|
+
require 'active_record'
|
|
27
|
+
require 'active_record/version'
|
|
28
|
+
puts "version #{ActiveRecord::VERSION::STRING}"
|
|
29
|
+
rescue LoadError
|
|
30
|
+
puts "FAILED."
|
|
31
|
+
print "Loading ActiveRecord with gems..."
|
|
32
|
+
require 'rubygems'
|
|
33
|
+
gem 'activerecord'
|
|
34
|
+
puts "version #{Gem.loaded_specs['activerecord'].version.version}"
|
|
35
|
+
require 'active_record'
|
|
36
|
+
end
|
|
37
|
+
require 'benchmark'
|
|
38
|
+
|
|
39
|
+
if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
|
|
40
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
|
41
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../drivers/mysql/lib'
|
|
42
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../adapters/mysql/lib'
|
|
43
|
+
require 'active_record/connection_adapters/jdbcmysql_adapter'
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
if ENV['LOGGER']
|
|
47
|
+
require 'logger'
|
|
48
|
+
ActiveRecord::Base.logger = Logger.new(File.expand_path(File.dirname(__FILE__) + "/debug.log"))
|
|
49
|
+
lvl = %(DEBUG INFO WARN ERROR FATAL).detect {|s| s =~ /#{ENV['LOGGER'].upcase}/}
|
|
50
|
+
ActiveRecord::Base.logger.level = lvl && Logger.const_get(lvl) || Logger::INFO
|
|
51
|
+
else
|
|
52
|
+
ActiveRecord::Base.logger = Logger.new($stdout)
|
|
53
|
+
ActiveRecord::Base.logger.level = Logger::UNKNOWN
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
ActiveRecord::Base.establish_connection(
|
|
57
|
+
:adapter => "mysql",
|
|
58
|
+
:host => "localhost",
|
|
59
|
+
:username => "root",
|
|
60
|
+
:database => "ar_bench",
|
|
61
|
+
:pool => 10,
|
|
62
|
+
:wait_timeout => 0.5
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
class CreateWidgets < ActiveRecord::Migration
|
|
66
|
+
def self.up
|
|
67
|
+
create_table :widgets do |t|
|
|
68
|
+
t.string :name
|
|
69
|
+
t.text :description
|
|
70
|
+
t.timestamps
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
CreateWidgets.up unless ActiveRecord::Base.connection.tables.include?("widgets")
|
|
76
|
+
|
|
77
|
+
class Widget < ActiveRecord::Base; end
|
|
78
|
+
Widget.destroy_all if Widget.count > ROW_COUNT
|
|
79
|
+
count = Widget.count
|
|
80
|
+
while (count < ROW_COUNT)
|
|
81
|
+
Widget.create!(:name => "bench#{count}", :description => "Bench record#{count}")
|
|
82
|
+
count = Widget.count
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
ActiveRecord::Base.clear_active_connections!
|