cmoran92-activerecord-jdbc-adapter 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +22 -0
- data/.travis.yml +8 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +42 -0
- data/History.txt +469 -0
- data/LICENSE.txt +21 -0
- data/README.rdoc +199 -0
- data/Rakefile +60 -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/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 +25 -0
- data/lib/arel/visitors/firebird.rb +24 -0
- data/lib/arel/visitors/hsqldb.rb +26 -0
- data/lib/arel/visitors/sql_server.rb +44 -0
- data/lib/arjdbc.rb +24 -0
- data/lib/arjdbc/db2.rb +2 -0
- data/lib/arjdbc/db2/adapter.rb +510 -0
- data/lib/arjdbc/derby.rb +7 -0
- data/lib/arjdbc/derby/adapter.rb +351 -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 +136 -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 +138 -0
- data/lib/arjdbc/informix/connection_methods.rb +11 -0
- data/lib/arjdbc/jdbc.rb +2 -0
- data/lib/arjdbc/jdbc/adapter.rb +354 -0
- data/lib/arjdbc/jdbc/adapter_java.jar +0 -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 +87 -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 +468 -0
- data/lib/arjdbc/mssql/connection_methods.rb +31 -0
- data/lib/arjdbc/mssql/limit_helpers.rb +108 -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 +428 -0
- data/lib/arjdbc/oracle/connection_methods.rb +12 -0
- data/lib/arjdbc/postgresql.rb +4 -0
- data/lib/arjdbc/postgresql/adapter.rb +825 -0
- data/lib/arjdbc/postgresql/connection_methods.rb +23 -0
- data/lib/arjdbc/sqlite3.rb +4 -0
- data/lib/arjdbc/sqlite3/adapter.rb +387 -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 +62 -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 +1331 -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 +9 -0
- data/test/db/sqlite3.rb +11 -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_simple_test.rb +99 -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 +85 -0
- data/test/hsqldb_simple_test.rb +6 -0
- data/test/informix_simple_test.rb +48 -0
- data/test/jdbc_common.rb +27 -0
- data/test/jndi_callbacks_test.rb +40 -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/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_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_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_simple_test.rb +125 -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 +89 -0
- data/test/postgres_nonseq_pkey_test.rb +38 -0
- data/test/postgres_reserved_test.rb +22 -0
- data/test/postgres_schema_search_path_test.rb +48 -0
- data/test/postgres_simple_test.rb +167 -0
- data/test/postgres_table_alias_length_test.rb +15 -0
- data/test/postgres_type_conversion_test.rb +34 -0
- data/test/simple.rb +658 -0
- data/test/sqlite3_simple_test.rb +284 -0
- data/test/sybase_jtds_simple_test.rb +28 -0
- metadata +261 -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,199 @@
|
|
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 discover
|
15
|
+
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 (<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.
|
27
|
+
* mysql (<tt>activerecord-jdbcmysql-adapter</tt>)
|
28
|
+
* postgresql (<tt>activerecord-jdbcpostgresql-adapter</tt>)
|
29
|
+
* sqlite3 (<tt>activerecord-jdbcsqlite3-adapter</tt>)
|
30
|
+
* derby (<tt>activerecord-jdbcderby-adapter</tt>)
|
31
|
+
* hsqldb (<tt>activerecord-jdbchsqldb-adapter</tt>)
|
32
|
+
* h2 (<tt>activerecord-jdbch2-adapter</tt>)
|
33
|
+
* mssql (<tt>activerecord-jdbcmssql-adapter</tt>)
|
34
|
+
|
35
|
+
2a. For Rails 3, if you're generating a new application, use the
|
36
|
+
following command to generate your application:
|
37
|
+
|
38
|
+
jruby -S rails new sweetapp
|
39
|
+
|
40
|
+
2b. Otherwise, you'll need to perform some extra configuration steps
|
41
|
+
to prepare your Rails application for JDBC.
|
42
|
+
|
43
|
+
If you're using Rails 3, you'll need to modify your Gemfile to use the
|
44
|
+
activerecord-jdbc-adapter gem under JRuby. Change your Gemfile to look
|
45
|
+
like the following (using sqlite3 as an example):
|
46
|
+
|
47
|
+
platforms :ruby do
|
48
|
+
gem 'sqlite3'
|
49
|
+
end
|
50
|
+
|
51
|
+
platforms :jruby do
|
52
|
+
gem 'jruby-openssl'
|
53
|
+
gem 'activerecord-jdbcsqlite3-adapter'
|
54
|
+
end
|
55
|
+
|
56
|
+
If you're using Rails 2:
|
57
|
+
|
58
|
+
jruby script/generate jdbc
|
59
|
+
|
60
|
+
3. Configure your database.yml in the normal Rails style.
|
61
|
+
|
62
|
+
Legacy configuration: If you use one of the convenience
|
63
|
+
'activerecord-jdbcXXX-adapter' adapters, you can still put a 'jdbc'
|
64
|
+
prefix in front of the database adapter name as below.
|
65
|
+
|
66
|
+
development:
|
67
|
+
adapter: jdbcmysql
|
68
|
+
username: blog
|
69
|
+
password:
|
70
|
+
hostname: localhost
|
71
|
+
database: weblog_development
|
72
|
+
|
73
|
+
For other databases, you'll need to know the database driver class and
|
74
|
+
URL. Example:
|
75
|
+
|
76
|
+
development:
|
77
|
+
adapter: jdbc
|
78
|
+
username: blog
|
79
|
+
password:
|
80
|
+
driver: com.mysql.jdbc.Driver
|
81
|
+
url: jdbc:mysql://localhost:3306/weblog_development
|
82
|
+
|
83
|
+
For JNDI data sources, you may simply specify the JNDI location as follows
|
84
|
+
(the adapter will be automatically detected):
|
85
|
+
|
86
|
+
production:
|
87
|
+
adapter: jdbc
|
88
|
+
jndi: jdbc/mysqldb
|
89
|
+
|
90
|
+
If you're really old school you might want to use ARJDBC with a DB2 on z/OS.
|
91
|
+
|
92
|
+
development:
|
93
|
+
adapter: jdbc
|
94
|
+
encoding: unicode
|
95
|
+
url: jdbc:db2j:net://mightyzoshost:446/RAILS_DBT1
|
96
|
+
driver: com.ibm.db2.jcc.DB2Driver
|
97
|
+
schema: DB2XB12
|
98
|
+
database: RAILS_DB1
|
99
|
+
tablespace: TSDE911
|
100
|
+
lob_tablespaces:
|
101
|
+
first_table: TSDE912
|
102
|
+
username: scott
|
103
|
+
password: lion
|
104
|
+
|
105
|
+
=== Standalone, with ActiveRecord
|
106
|
+
|
107
|
+
1. Install the gem with JRuby:
|
108
|
+
|
109
|
+
jruby -S gem install activerecord-jdbc-adapter
|
110
|
+
|
111
|
+
If you wish to use the adapter for a specific database, you can
|
112
|
+
install it directly and a driver gem will be installed as well:
|
113
|
+
|
114
|
+
jruby -S gem install activerecord-jdbcderby-adapter
|
115
|
+
|
116
|
+
2. After this you can establish a JDBC connection like this:
|
117
|
+
|
118
|
+
ActiveRecord::Base.establish_connection(
|
119
|
+
:adapter => 'jdbcderby',
|
120
|
+
:database => "db/my-database"
|
121
|
+
)
|
122
|
+
|
123
|
+
or like this (but requires that you manually put the driver jar on the classpath):
|
124
|
+
|
125
|
+
ActiveRecord::Base.establish_connection(
|
126
|
+
:adapter => 'jdbc',
|
127
|
+
:driver => 'org.apache.derby.jdbc.EmbeddedDriver',
|
128
|
+
:url => 'jdbc:derby:test_ar;create=true'
|
129
|
+
)
|
130
|
+
|
131
|
+
== Extending AR-JDBC
|
132
|
+
|
133
|
+
You can create your own extension to AR-JDBC for a JDBC-based database
|
134
|
+
that core AR-JDBC does not support. We've created an example project
|
135
|
+
for the Intersystems Cache database that you can examine as a
|
136
|
+
template. See the project for more information at the following URL:
|
137
|
+
|
138
|
+
http://github.com/nicksieger/activerecord-cachedb-adapter
|
139
|
+
|
140
|
+
== Getting the source
|
141
|
+
|
142
|
+
The source for activerecord-jdbc-adapter is available using git.
|
143
|
+
|
144
|
+
git clone git://github.com/jruby/activerecord-jdbc-adapter.git
|
145
|
+
|
146
|
+
== Feedback
|
147
|
+
|
148
|
+
Please file bug reports at
|
149
|
+
http://kenai.com/jira/browse/ACTIVERECORD_JDBC. If you're not sure if
|
150
|
+
something's a bug, feel free to pre-report it on the mailing lists.
|
151
|
+
|
152
|
+
== Project Info
|
153
|
+
|
154
|
+
* Mailing Lists: http://jruby.org/community
|
155
|
+
* Issues: https://github.com/jruby/activerecord-jdbc-adapter/issues
|
156
|
+
* Source: git://github.com/jruby/activerecord-jdbc-adapter.git
|
157
|
+
|
158
|
+
== Running AR-JDBC's Tests
|
159
|
+
|
160
|
+
Drivers for 6 open-source databases are included. Provided you have
|
161
|
+
MySQL installed, you can simply type <tt>jruby -S rake</tt> to run the
|
162
|
+
tests. A database named <tt>weblog_development</tt> is needed
|
163
|
+
beforehand with a connection user of "blog" and an empty password. You
|
164
|
+
alse need to grant "blog" create privileges on
|
165
|
+
'test_rake_db_create.*'.
|
166
|
+
|
167
|
+
If you also have PostgreSQL available, those tests will be run if the
|
168
|
+
`psql' executable can be found. Also ensure you have a database named
|
169
|
+
<tt>weblog_development</tt> and a user named "blog" and an empty
|
170
|
+
password.
|
171
|
+
|
172
|
+
If you want rails logging enabled during these test runs you can edit
|
173
|
+
test/jdbc_common.rb and add the following line:
|
174
|
+
|
175
|
+
require 'db/logger'
|
176
|
+
|
177
|
+
== Running AR Tests
|
178
|
+
|
179
|
+
To run the current AR-JDBC sources with ActiveRecord, just use the
|
180
|
+
included "rails:test" task. Be sure to specify a driver and a path to
|
181
|
+
the ActiveRecord sources.
|
182
|
+
|
183
|
+
jruby -S rake rails:test DRIVER=mysql RAILS=/path/activerecord_source_dir
|
184
|
+
|
185
|
+
== Travis Build Status {<img src="https://secure.travis-ci.org/jruby/activerecord-jdbc-adapter.png"/>}[http://travis-ci.org/#!/jruby/activerecord-jdbc-adapter]
|
186
|
+
|
187
|
+
== Authors
|
188
|
+
|
189
|
+
This project was written by Nick Sieger <nick@nicksieger.com> and Ola Bini
|
190
|
+
<olabini@gmail.com> with lots of help from the JRuby community.
|
191
|
+
|
192
|
+
== License
|
193
|
+
|
194
|
+
activerecord-jdbc-adapter is released under a BSD license. See the LICENSE file
|
195
|
+
included with the distribution for details.
|
196
|
+
|
197
|
+
Open-source driver gems for activerecord-jdbc-adapter are licensed under the
|
198
|
+
same license the database's drivers are licensed. See each driver gem's
|
199
|
+
LICENSE.txt file for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,60 @@
|
|
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 File.expand_path('../test/helper', __FILE__)
|
10
|
+
|
11
|
+
task :default => [:jar, :test]
|
12
|
+
|
13
|
+
#ugh, bundler doesn't use tasks, so gotta hook up to both tasks.
|
14
|
+
task :build => :jar
|
15
|
+
task :install => :jar
|
16
|
+
|
17
|
+
ADAPTERS = %w[derby h2 hsqldb mssql mysql postgresql sqlite3].map {|a| "activerecord-jdbc#{a}-adapter" }
|
18
|
+
DRIVERS = %w[derby h2 hsqldb jtds mysql postgres sqlite3].map {|a| "jdbc-#{a}" }
|
19
|
+
|
20
|
+
def rake(args)
|
21
|
+
ruby "-S", "rake", *args
|
22
|
+
end
|
23
|
+
|
24
|
+
(ADAPTERS + DRIVERS).each do |adapter|
|
25
|
+
namespace adapter do
|
26
|
+
|
27
|
+
task :build do
|
28
|
+
Dir.chdir(adapter) do
|
29
|
+
rake "build"
|
30
|
+
end
|
31
|
+
cp FileList["#{adapter}/pkg/#{adapter}-*.gem"], "pkg"
|
32
|
+
end
|
33
|
+
|
34
|
+
# bundler handles install => build itself
|
35
|
+
task :install do
|
36
|
+
Dir.chdir(adapter) do
|
37
|
+
rake "install"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
task :release do
|
42
|
+
Dir.chdir(adapter) do
|
43
|
+
rake "release"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "Release all adapters"
|
50
|
+
task "all:release" => ["release", *ADAPTERS.map { |f| "#{f}:release" }]
|
51
|
+
|
52
|
+
desc "Install all adapters"
|
53
|
+
task "all:install" => ["install", *ADAPTERS.map { |f| "#{f}:install" }]
|
54
|
+
|
55
|
+
desc "Build all adapters"
|
56
|
+
task "all:build" => ["build", *ADAPTERS.map { |f| "#{f}:build" }]
|
57
|
+
|
58
|
+
task :filelist do
|
59
|
+
puts FileList['pkg/**/*'].inspect
|
60
|
+
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 = "cmoran92-activerecord-jdbc-adapter"
|
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. Includes patch by cmoran92 to eliminate duplicates when SELECTing DISTING with JOINS on MS SQL Server. }
|
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.txt", "-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!
|