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.
Files changed (282) hide show
  1. data/.gitignore +14 -8
  2. data/.travis.yml +40 -31
  3. data/.yardopts +4 -0
  4. data/Appraisals +2 -5
  5. data/CONTRIBUTING.md +46 -0
  6. data/Gemfile +21 -4
  7. data/Gemfile.lock +42 -17
  8. data/{History.txt → History.md} +142 -75
  9. data/README.md +102 -104
  10. data/RUNNING_TESTS.md +76 -0
  11. data/Rakefile.jdbc +20 -0
  12. data/activerecord-jdbc-adapter.gemspec +35 -18
  13. data/gemfiles/rails23.gemfile +4 -3
  14. data/gemfiles/rails23.gemfile.lock +9 -6
  15. data/gemfiles/rails30.gemfile +4 -3
  16. data/gemfiles/rails30.gemfile.lock +9 -6
  17. data/gemfiles/rails31.gemfile +4 -3
  18. data/gemfiles/rails31.gemfile.lock +9 -6
  19. data/gemfiles/rails32.gemfile +4 -3
  20. data/gemfiles/rails32.gemfile.lock +17 -14
  21. data/gemfiles/rails40.gemfile +5 -5
  22. data/gemfiles/rails40.gemfile.lock +17 -69
  23. data/lib/active_record/connection_adapters/firebird_adapter.rb +1 -0
  24. data/lib/active_record/connection_adapters/sqlserver_adapter.rb +1 -0
  25. data/lib/arel/visitors/compat.rb +22 -3
  26. data/lib/arel/visitors/db2.rb +8 -4
  27. data/lib/arel/visitors/derby.rb +14 -13
  28. data/lib/arel/visitors/firebird.rb +5 -4
  29. data/lib/arel/visitors/hsqldb.rb +11 -9
  30. data/lib/arel/visitors/sql_server.rb +89 -61
  31. data/lib/arjdbc.rb +1 -1
  32. data/lib/arjdbc/db2/adapter.rb +181 -212
  33. data/lib/arjdbc/db2/as400.rb +31 -18
  34. data/lib/arjdbc/db2/column.rb +167 -0
  35. data/lib/arjdbc/db2/connection_methods.rb +2 -0
  36. data/lib/arjdbc/derby/adapter.rb +206 -107
  37. data/lib/arjdbc/derby/connection_methods.rb +4 -9
  38. data/lib/arjdbc/firebird.rb +1 -0
  39. data/lib/arjdbc/firebird/adapter.rb +202 -64
  40. data/lib/arjdbc/firebird/connection_methods.rb +20 -0
  41. data/lib/arjdbc/h2/adapter.rb +56 -36
  42. data/lib/arjdbc/hsqldb/adapter.rb +99 -68
  43. data/lib/arjdbc/jdbc/adapter.rb +474 -265
  44. data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
  45. data/lib/arjdbc/jdbc/adapter_require.rb +8 -7
  46. data/lib/arjdbc/jdbc/arel_support.rb +132 -0
  47. data/lib/arjdbc/jdbc/base_ext.rb +8 -7
  48. data/lib/arjdbc/jdbc/callbacks.rb +16 -10
  49. data/lib/arjdbc/jdbc/column.rb +25 -3
  50. data/lib/arjdbc/jdbc/connection.rb +28 -55
  51. data/lib/arjdbc/jdbc/extension.rb +14 -14
  52. data/lib/arjdbc/jdbc/java.rb +6 -3
  53. data/lib/arjdbc/jdbc/jdbc.rake +1 -1
  54. data/lib/arjdbc/jdbc/quoted_primary_key.rb +2 -2
  55. data/lib/arjdbc/jdbc/rake_tasks.rb +1 -1
  56. data/lib/arjdbc/jdbc/type_converter.rb +5 -2
  57. data/lib/arjdbc/mssql/adapter.rb +160 -280
  58. data/lib/arjdbc/mssql/column.rb +182 -0
  59. data/lib/arjdbc/mssql/connection_methods.rb +37 -4
  60. data/lib/arjdbc/mssql/explain_support.rb +13 -21
  61. data/lib/arjdbc/mssql/limit_helpers.rb +79 -42
  62. data/lib/arjdbc/mssql/lock_methods.rb +77 -0
  63. data/lib/arjdbc/mssql/utils.rb +11 -11
  64. data/lib/arjdbc/mysql/adapter.rb +165 -247
  65. data/lib/arjdbc/mysql/column.rb +123 -0
  66. data/lib/arjdbc/mysql/connection_methods.rb +3 -6
  67. data/lib/arjdbc/oracle/adapter.rb +282 -288
  68. data/lib/arjdbc/oracle/column.rb +122 -0
  69. data/lib/arjdbc/oracle/connection_methods.rb +3 -0
  70. data/lib/arjdbc/postgresql/adapter.rb +336 -574
  71. data/lib/arjdbc/postgresql/column.rb +458 -0
  72. data/lib/arjdbc/postgresql/connection_methods.rb +1 -2
  73. data/lib/arjdbc/postgresql/schema_creation.rb +38 -0
  74. data/lib/arjdbc/sqlite3/adapter.rb +189 -145
  75. data/lib/arjdbc/sqlite3/explain_support.rb +1 -1
  76. data/lib/arjdbc/tasks/oracle/enhanced_structure_dump.rb +8 -8
  77. data/lib/arjdbc/util/quoted_cache.rb +60 -0
  78. data/lib/arjdbc/util/table_copier.rb +110 -0
  79. data/lib/arjdbc/version.rb +6 -7
  80. data/pom.xml +56 -2
  81. data/rakelib/02-test.rake +72 -83
  82. data/rakelib/db.rake +29 -17
  83. data/src/java/arjdbc/ArJdbcModule.java +21 -18
  84. data/src/java/arjdbc/db2/DB2RubyJdbcConnection.java +84 -12
  85. data/src/java/arjdbc/derby/DerbyModule.java +140 -143
  86. data/src/java/arjdbc/derby/DerbyRubyJdbcConnection.java +58 -7
  87. data/src/java/arjdbc/h2/H2Module.java +43 -0
  88. data/src/java/arjdbc/informix/InformixRubyJdbcConnection.java +7 -6
  89. data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +1223 -648
  90. data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +24 -23
  91. data/src/java/arjdbc/mysql/MySQLModule.java +33 -32
  92. data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +147 -30
  93. data/src/java/arjdbc/oracle/OracleModule.java +13 -13
  94. data/src/java/arjdbc/oracle/OracleRubyJdbcConnection.java +114 -6
  95. data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +166 -36
  96. data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +101 -19
  97. data/src/java/arjdbc/util/QuotingUtils.java +19 -19
  98. metadata +240 -394
  99. data/bench/bench_attributes.rb +0 -13
  100. data/bench/bench_attributes_new.rb +0 -14
  101. data/bench/bench_create.rb +0 -12
  102. data/bench/bench_find_all.rb +0 -12
  103. data/bench/bench_find_all_mt.rb +0 -25
  104. data/bench/bench_model.rb +0 -85
  105. data/bench/bench_new.rb +0 -12
  106. data/bench/bench_new_valid.rb +0 -12
  107. data/bench/bench_valid.rb +0 -13
  108. data/lib/arel/engines/sql/compilers/db2_compiler.rb +0 -9
  109. data/lib/arel/engines/sql/compilers/derby_compiler.rb +0 -6
  110. data/lib/arel/engines/sql/compilers/h2_compiler.rb +0 -6
  111. data/lib/arel/engines/sql/compilers/hsqldb_compiler.rb +0 -15
  112. data/lib/arel/engines/sql/compilers/jdbc_compiler.rb +0 -6
  113. data/lib/arel/engines/sql/compilers/mssql_compiler.rb +0 -46
  114. data/lib/arjdbc/jdbc/missing_functionality_helper.rb +0 -98
  115. data/lib/arjdbc/mssql/lock_helpers.rb +0 -76
  116. data/lib/arjdbc/mssql/tsql_methods.rb +0 -58
  117. data/lib/arjdbc/postgresql/column_cast.rb +0 -134
  118. data/test/activerecord/connections/native_jdbc_mysql/connection.rb +0 -25
  119. data/test/activerecord/jall.sh +0 -7
  120. data/test/activerecord/jtest.sh +0 -3
  121. data/test/assets/flowers.jpg +0 -0
  122. data/test/binary.rb +0 -67
  123. data/test/db/db2.rb +0 -43
  124. data/test/db/db2/binary_test.rb +0 -6
  125. data/test/db/db2/has_many_through_test.rb +0 -6
  126. data/test/db/db2/rake_test.rb +0 -82
  127. data/test/db/db2/rake_test_data.sql +0 -35
  128. data/test/db/db2/reset_column_information_test.rb +0 -5
  129. data/test/db/db2/serialize_test.rb +0 -6
  130. data/test/db/db2/simple_test.rb +0 -81
  131. data/test/db/db2/test_helper.rb +0 -6
  132. data/test/db/db2/unit_test.rb +0 -73
  133. data/test/db/derby.rb +0 -12
  134. data/test/db/derby/binary_test.rb +0 -6
  135. data/test/db/derby/migration_test.rb +0 -74
  136. data/test/db/derby/rake_test.rb +0 -96
  137. data/test/db/derby/reset_column_information_test.rb +0 -6
  138. data/test/db/derby/row_locking_test.rb +0 -20
  139. data/test/db/derby/schema_dump_test.rb +0 -5
  140. data/test/db/derby/serialize_test.rb +0 -6
  141. data/test/db/derby/simple_test.rb +0 -173
  142. data/test/db/derby/test_helper.rb +0 -6
  143. data/test/db/derby/unit_test.rb +0 -32
  144. data/test/db/derby/xml_column_test.rb +0 -17
  145. data/test/db/h2.rb +0 -11
  146. data/test/db/h2/binary_test.rb +0 -6
  147. data/test/db/h2/change_column_test.rb +0 -68
  148. data/test/db/h2/identity_column_test.rb +0 -35
  149. data/test/db/h2/offset_test.rb +0 -49
  150. data/test/db/h2/rake_test.rb +0 -98
  151. data/test/db/h2/schema_dump_test.rb +0 -29
  152. data/test/db/h2/serialize_test.rb +0 -6
  153. data/test/db/h2/simple_test.rb +0 -56
  154. data/test/db/hsqldb.rb +0 -11
  155. data/test/db/hsqldb/binary_test.rb +0 -6
  156. data/test/db/hsqldb/rake_test.rb +0 -101
  157. data/test/db/hsqldb/schema_dump_test.rb +0 -19
  158. data/test/db/hsqldb/serialize_test.rb +0 -6
  159. data/test/db/hsqldb/simple_test.rb +0 -17
  160. data/test/db/informix.rb +0 -13
  161. data/test/db/jdbc.rb +0 -16
  162. data/test/db/jdbc_derby.rb +0 -14
  163. data/test/db/jdbc_h2.rb +0 -17
  164. data/test/db/jdbc_mysql.rb +0 -13
  165. data/test/db/jdbc_postgres.rb +0 -23
  166. data/test/db/jndi_config.rb +0 -32
  167. data/test/db/jndi_pooled_config.rb +0 -32
  168. data/test/db/mssql.rb +0 -11
  169. data/test/db/mssql/binary_test.rb +0 -6
  170. data/test/db/mssql/exec_proc_test.rb +0 -46
  171. data/test/db/mssql/identity_insert_test.rb +0 -18
  172. data/test/db/mssql/ignore_system_views_test.rb +0 -40
  173. data/test/db/mssql/limit_offset_test.rb +0 -190
  174. data/test/db/mssql/multibyte_test.rb +0 -16
  175. data/test/db/mssql/multiple_connections_test.rb +0 -71
  176. data/test/db/mssql/rake_test.rb +0 -143
  177. data/test/db/mssql/reset_column_information_test.rb +0 -6
  178. data/test/db/mssql/row_locking_test.rb +0 -7
  179. data/test/db/mssql/serialize_test.rb +0 -6
  180. data/test/db/mssql/simple_test.rb +0 -140
  181. data/test/db/mssql/transaction_test.rb +0 -6
  182. data/test/db/mssql/types_test.rb +0 -205
  183. data/test/db/mssql/unit_test.rb +0 -249
  184. data/test/db/mysql.rb +0 -4
  185. data/test/db/mysql/_rails_test_mysql.32.out +0 -6585
  186. data/test/db/mysql/binary_test.rb +0 -6
  187. data/test/db/mysql/connection_test.rb +0 -51
  188. data/test/db/mysql/index_length_test.rb +0 -58
  189. data/test/db/mysql/multibyte_test.rb +0 -10
  190. data/test/db/mysql/nonstandard_primary_key_test.rb +0 -39
  191. data/test/db/mysql/rake_test.rb +0 -97
  192. data/test/db/mysql/reset_column_information_test.rb +0 -6
  193. data/test/db/mysql/schema_dump_test.rb +0 -228
  194. data/test/db/mysql/serialize_test.rb +0 -6
  195. data/test/db/mysql/simple_test.rb +0 -187
  196. data/test/db/mysql/statement_escaping_test.rb +0 -46
  197. data/test/db/mysql/transaction_test.rb +0 -6
  198. data/test/db/mysql/types_test.rb +0 -30
  199. data/test/db/mysql/unit_test.rb +0 -93
  200. data/test/db/mysql_config.rb +0 -7
  201. data/test/db/oracle.rb +0 -27
  202. data/test/db/oracle/binary_test.rb +0 -6
  203. data/test/db/oracle/limit_test.rb +0 -24
  204. data/test/db/oracle/multibyte_test.rb +0 -22
  205. data/test/db/oracle/rake_test.rb +0 -100
  206. data/test/db/oracle/reset_column_information_test.rb +0 -6
  207. data/test/db/oracle/serialize_test.rb +0 -6
  208. data/test/db/oracle/simple_test.rb +0 -140
  209. data/test/db/oracle/specific_test.rb +0 -180
  210. data/test/db/oracle/transaction_test.rb +0 -31
  211. data/test/db/oracle/unit_test.rb +0 -31
  212. data/test/db/postgres.rb +0 -11
  213. data/test/db/postgres/_rails_test_postgres.32.out +0 -6405
  214. data/test/db/postgres/a_custom_primary_key_test.rb +0 -50
  215. data/test/db/postgres/active_schema_unit_test.rb +0 -68
  216. data/test/db/postgres/array_type_test.rb +0 -101
  217. data/test/db/postgres/binary_test.rb +0 -6
  218. data/test/db/postgres/connection_test.rb +0 -63
  219. data/test/db/postgres/data_types_test.rb +0 -703
  220. data/test/db/postgres/hstore_test.rb +0 -200
  221. data/test/db/postgres/information_schema_leak_test.rb +0 -30
  222. data/test/db/postgres/json_test.rb +0 -86
  223. data/test/db/postgres/ltree_test.rb +0 -51
  224. data/test/db/postgres/mixed_case_test.rb +0 -29
  225. data/test/db/postgres/native_types_test.rb +0 -124
  226. data/test/db/postgres/rake_test.rb +0 -117
  227. data/test/db/postgres/reserved_test.rb +0 -22
  228. data/test/db/postgres/reset_column_information_test.rb +0 -6
  229. data/test/db/postgres/row_locking_test.rb +0 -21
  230. data/test/db/postgres/schema_dump_test.rb +0 -95
  231. data/test/db/postgres/schema_test.rb +0 -115
  232. data/test/db/postgres/simple_test.rb +0 -260
  233. data/test/db/postgres/table_alias_length_test.rb +0 -16
  234. data/test/db/postgres/transaction_test.rb +0 -6
  235. data/test/db/postgres/unit_test.rb +0 -31
  236. data/test/db/postgres_config.rb +0 -10
  237. data/test/db/sqlite3.rb +0 -6
  238. data/test/db/sqlite3/_rails_test_sqlite3.32.out +0 -6274
  239. data/test/db/sqlite3/has_many_though_test.rb +0 -6
  240. data/test/db/sqlite3/rake_test.rb +0 -71
  241. data/test/db/sqlite3/reset_column_information_test.rb +0 -6
  242. data/test/db/sqlite3/schema_dump_test.rb +0 -6
  243. data/test/db/sqlite3/serialize_test.rb +0 -6
  244. data/test/db/sqlite3/simple_test.rb +0 -268
  245. data/test/db/sqlite3/transaction_test.rb +0 -32
  246. data/test/db/sqlite3/type_conversion_test.rb +0 -104
  247. data/test/has_many_through.rb +0 -61
  248. data/test/informix_simple_test.rb +0 -48
  249. data/test/jdbc/db2.rb +0 -36
  250. data/test/jdbc/oracle.rb +0 -34
  251. data/test/jdbc_column_test.rb +0 -23
  252. data/test/jdbc_common.rb +0 -16
  253. data/test/jdbc_connection_test.rb +0 -196
  254. data/test/jndi_callbacks_test.rb +0 -33
  255. data/test/jndi_test.rb +0 -55
  256. data/test/manualTestDatabase.rb +0 -191
  257. data/test/models/add_not_null_column_to_table.rb +0 -9
  258. data/test/models/auto_id.rb +0 -15
  259. data/test/models/binary.rb +0 -18
  260. data/test/models/custom_pk_name.rb +0 -15
  261. data/test/models/data_types.rb +0 -40
  262. data/test/models/entry.rb +0 -41
  263. data/test/models/mixed_case.rb +0 -22
  264. data/test/models/reserved_word.rb +0 -15
  265. data/test/models/rights_and_roles.rb +0 -57
  266. data/test/models/string_id.rb +0 -17
  267. data/test/models/thing.rb +0 -17
  268. data/test/models/topic.rb +0 -32
  269. data/test/models/validates_uniqueness_of_string.rb +0 -19
  270. data/test/rails/mysql.rb +0 -13
  271. data/test/rails/sqlite3/version.rb +0 -6
  272. data/test/rails_stub.rb +0 -31
  273. data/test/rake_test_support.rb +0 -298
  274. data/test/row_locking.rb +0 -102
  275. data/test/schema_dump.rb +0 -182
  276. data/test/serialize.rb +0 -275
  277. data/test/shared_helper.rb +0 -35
  278. data/test/simple.rb +0 -1317
  279. data/test/sybase_jtds_simple_test.rb +0 -28
  280. data/test/sybase_reset_column_information_test.rb +0 -6
  281. data/test/test_helper.rb +0 -304
  282. 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, it's
8
- latest version is compatible with JRuby 1.6.8+ (but as always we recommend to
9
- use the latest and greatest of JRubies) thus requires Java 1.6 at minimum.
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.0** of AR-JDBC adapter is currently in the making which
12
- strives to provide ActiveRecord 2.3, 3.x as well as 4.0 (master) compatibility.
13
- Our master already contains a lot of fixes but since we diverged significantly
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
- **NOTE:** activerecord-jdbc-adapter gem **1.2.6** contains a SQL injection
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 `activerecord-jdbc-adapter` with JRuby on Rails :
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 via
44
- JDBC, but requires you to download and manually setup the database vendor's
45
- JDBC driver .jar file.
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`) - does not support SQL Azure by default,
53
- see the [README][2] for more information.
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 sqlite3 as an example) :
58
+ like the following (using MySQL as an example):
66
59
 
67
60
  ```ruby
68
- gem 'sqlite3', :platform => :ruby
61
+ gem 'mysql', platform: :ruby
69
62
 
70
63
  platforms :jruby do
71
64
  gem 'jruby-openssl'
72
- gem 'activerecord-jdbcsqlite3-adapter'
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: jdbcmysql
77
+ adapter: mysql
89
78
  username: blog
90
- password:
79
+ password: 1234
91
80
  host: localhost
92
- database: weblog_development
81
+ database: blog_development
93
82
  ```
94
83
 
95
- For plain JDBC database configurations, you'll need to know the database driver
96
- class and URL (do not forget to put the driver jar on the class-path) e.g. :
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/weblog_development
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/mysqldb
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/weblog?profileSQL=true"
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
- ### Standalone (with ActiveRecord)
148
+ More information on (configuring) AR-JDBC might be found on our [wiki][5].
155
149
 
156
- 1. Install the gem with JRuby:
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
- 2. After this you can establish a JDBC connection like this :
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
- :adapter => 'derby', # or 'jdbcderby'
170
- :database => "db/my-database"
156
+ adapter: 'derby',
157
+ database: 'db/my-database'
171
158
  )
172
159
  ```
173
160
 
174
- or like (but requires that you manually put the driver jar on the classpath) :
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
- ## Source
171
+ #### Using Bundler
185
172
 
186
- The source for activerecord-jdbc-adapter is available using git :
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
- git clone git://github.com/jruby/activerecord-jdbc-adapter.git
176
+ ```ruby
177
+ gem 'activerecord', '~> 3.2.13'
178
+ gem 'activerecord-jdbcmysql-adapter', :platform => :jruby
179
+ ```
189
180
 
190
- Please note that the project manages multiple gems from a single repository,
191
- if you're using *Bundler* 1.2 it should be able to locate all gemspecs from
192
- the git repository. Sample *Gemfile* for running with (MySQL) master :
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-jdbc-adapter', :github => 'jruby/activerecord-jdbc-adapter'
196
- gem 'activerecord-jdbcmysql-adapter', :github => 'jruby/activerecord-jdbc-adapter'
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
- ## Running AR-JDBC Tests
192
+ #### Without Bundler
201
193
 
202
- [![Build Status][9]](http://travis-ci.org/#!/jruby/activerecord-jdbc-adapter)
194
+ Install the needed gems with JRuby:
203
195
 
204
- Drivers for 6 open-source databases are included. Provided you have
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 also have PostgreSQL available, those tests will be run if the
211
- `psql` executable can be found. Also ensure you have a database named
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
- To execute a single test case, you can run:
201
+ jruby -S gem install activerecord-jdbcderby-adapter
217
202
 
218
- rake appraisal:{version} test_{db} TEST=test/{tests_file}
203
+ Your program should include:
219
204
 
220
- Substitute the *version* of ActiveRecord for version, which can be one of :
221
- *rails23*, *rails30*, *rails31*, or *rails32*.
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
- The db can be one of these : *sqlite3*, *mysql*, *postgres*,
224
- *mssql*, *sybase*, *oracle*, *db2*, *derby*, *h2* or *hssql*.
212
+ ## Extending AR-JDBC
225
213
 
226
- Finally, the *tests_file* will be whichever (.rb) test case you want to run.
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
- ### Running AR Tests
219
+ ## Source
229
220
 
230
- To run the current AR-JDBC sources with `ActiveRecord`, just use the included
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
- jruby -S rake rails:test DRIVER=mysql RAILS=/path/rails_source_dir
223
+ git clone git://github.com/jruby/activerecord-jdbc-adapter.git
234
224
 
235
- ## Extending AR-JDBC
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
- You can create your own extension to AR-JDBC for a JDBC-based database
238
- that core AR-JDBC does not support. We've created an example project
239
- for the Intersystems Cache database that you can examine as a template.
240
- See the [cachedb-adapter project][4] for more information.
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 the LICENSE.txt file included with the distribution for details.
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
- [9]: https://secure.travis-ci.org/jruby/activerecord-jdbc-adapter.png
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 }