activerecord-oracle_enhanced-adapter 1.3.2 → 1.4.0
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/Gemfile +0 -2
- data/History.txt +19 -0
- data/README.md +378 -0
- data/RUNNING_TESTS.md +45 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/activerecord-oracle_enhanced-adapter.gemspec +6 -9
- data/lib/active_record/connection_adapters/oracle_enhanced.rake +34 -0
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +209 -57
- data/lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb +22 -1
- data/lib/active_record/connection_adapters/oracle_enhanced_column.rb +17 -3
- data/lib/active_record/connection_adapters/oracle_enhanced_context_index.rb +19 -3
- data/lib/active_record/connection_adapters/oracle_enhanced_jdbc_connection.rb +75 -17
- data/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb +41 -2
- data/lib/active_record/connection_adapters/oracle_enhanced_procedures.rb +3 -3
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_definitions.rb +40 -0
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_dumper.rb +10 -3
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_statements.rb +49 -10
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_statements_ext.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced_structure_dump.rb +54 -54
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +33 -5
- data/spec/active_record/connection_adapters/oracle_enhanced_context_index_spec.rb +66 -5
- data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +162 -13
- data/spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb +1 -0
- data/spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb +1 -0
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +43 -0
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +150 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +5 -4
- data/spec/spec_helper.rb +3 -1
- metadata +38 -52
- data/README.rdoc +0 -89
- data/RUNNING_TESTS.rdoc +0 -28
data/Gemfile
CHANGED
data/History.txt
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
== 1.4.0 2011-08-09
|
2
|
+
|
3
|
+
* Enhancements:
|
4
|
+
* Support for Rails 3.1
|
5
|
+
* Bind parameter support for exec_insert, exec_update and exec_delete (in ActiveRecord 3.1)
|
6
|
+
* Purge recyclebin on rake db:test:purge
|
7
|
+
* Support transactional context index
|
8
|
+
* Require ojdbc6.jar (on Java 6) or ojdbc5.jar (on Java 5) JDBC drivers
|
9
|
+
* Support for RAW data type
|
10
|
+
* rake db:create and db:drop tasks
|
11
|
+
* Support virtual columns (in Oracle 11g) in schema dump
|
12
|
+
* It is possible to specify default tablespaces for tables, indexes, CLOBs and BLOBs
|
13
|
+
* rename_index migrations method
|
14
|
+
* Search for JDBC driver in ./lib directory of Rails application
|
15
|
+
* Bug fixes:
|
16
|
+
* Fixed context index dump when definition is larger than 4000 bytes
|
17
|
+
* Fixed schema dump not to conflict with other database adapters that are used in the same application
|
18
|
+
* Allow $ in table name prefix or suffix
|
19
|
+
|
1
20
|
== 1.3.2 2011-01-05
|
2
21
|
|
3
22
|
* Enhancements:
|
data/README.md
ADDED
@@ -0,0 +1,378 @@
|
|
1
|
+
activerecord-oracle_enhanced-adapter
|
2
|
+
====================================
|
3
|
+
|
4
|
+
Oracle enhanced adapter for ActiveRecord
|
5
|
+
|
6
|
+
DESCRIPTION
|
7
|
+
-----------
|
8
|
+
|
9
|
+
Oracle enhanced ActiveRecord adapter provides Oracle database access from Ruby on Rails applications. Oracle enhanced adapter can be used from Ruby on Rails versions 2.3.x and 3.x and it is working with Oracle database versions 10g and 11g.
|
10
|
+
|
11
|
+
INSTALLATION
|
12
|
+
------------
|
13
|
+
|
14
|
+
### Rails 3
|
15
|
+
|
16
|
+
When using Ruby on Rails version 3 then in Gemfile include
|
17
|
+
|
18
|
+
gem 'activerecord-oracle_enhanced-adapter', '~> 1.4.0'
|
19
|
+
|
20
|
+
where instead of 1.4.0 you can specify any other desired version. It is recommended to specify version with `~>` which means that use specified version or later patch versions (in this example any later 1.4.x version but not 1.5.x version). Oracle enhanced adapter maintains API backwards compatibility during patch version upgrades and therefore it is safe to always upgrade to latest patch version.
|
21
|
+
|
22
|
+
If you would like to use latest adapter version from github then specify
|
23
|
+
|
24
|
+
gem 'activerecord-oracle_enhanced-adapter', :git => 'git://github.com/rsim/oracle-enhanced.git'
|
25
|
+
|
26
|
+
If you are using MRI 1.8 or 1.9 Ruby implementation then you need to install ruby-oci8 gem as well as Oracle client, e.g. [Oracle Instant Client](http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html). Include in Gemfile also ruby-oci8:
|
27
|
+
|
28
|
+
gem 'ruby-oci8', '~> 2.0.6'
|
29
|
+
|
30
|
+
If you are using JRuby then you need to download latest [Oracle JDBC driver](http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html) - either ojdbc6.jar for Java 6 or ojdbc5.jar for Java 5. And copy this file to one of these locations:
|
31
|
+
|
32
|
+
* in `./lib` directory of Rails application
|
33
|
+
* in some directory which is in `PATH`
|
34
|
+
* in `JRUBY_HOME/lib` directory
|
35
|
+
* or include path to JDBC driver jar file in Java `CLASSPATH`
|
36
|
+
|
37
|
+
After specifying necessary gems in Gemfile run
|
38
|
+
|
39
|
+
bundle install
|
40
|
+
|
41
|
+
to install the adapter (or later run `bundle update` to force updating to latest version).
|
42
|
+
|
43
|
+
### Rails 2.3
|
44
|
+
|
45
|
+
If you don't use Bundler in Rails 2 application then you need to specify gems in `config/environment.rb`, e.g.
|
46
|
+
|
47
|
+
Rails::Initializer.run do |config|
|
48
|
+
#...
|
49
|
+
config.gem 'activerecord-oracle_enhanced-adapter', :lib => "active_record/connection_adapters/oracle_enhanced_adapter"
|
50
|
+
config.gem 'ruby-oci8'
|
51
|
+
#...
|
52
|
+
end
|
53
|
+
|
54
|
+
But it is recommended to use Bundler for gem version management also for Rails 2.3 applications (search for instructions in Google).
|
55
|
+
|
56
|
+
### Without Rails and Bundler
|
57
|
+
|
58
|
+
If you want to use ActiveRecord and Oracle enhanced adapter without Rails and Bundler then install it just as a gem:
|
59
|
+
|
60
|
+
gem install activerecord-oracle_enhanced-adapter
|
61
|
+
|
62
|
+
USAGE
|
63
|
+
-----
|
64
|
+
|
65
|
+
### Database connection
|
66
|
+
|
67
|
+
In Rails application `config/database.yml` use oracle_enhanced as adapter name, e.g.
|
68
|
+
|
69
|
+
development:
|
70
|
+
adapter: oracle_enhanced
|
71
|
+
database: xe
|
72
|
+
username: user
|
73
|
+
password: secret
|
74
|
+
|
75
|
+
If `TNS_ADMIN` environment variable is pointing to directory where `tnsnames.ora` file is located then you can use TNS connection name in `database` parameter. Otherwise you can directly specify database host, port (defaults to 1521) and database name in the following way:
|
76
|
+
|
77
|
+
development:
|
78
|
+
adapter: oracle_enhanced
|
79
|
+
host: localhost
|
80
|
+
port: 1521
|
81
|
+
database: xe
|
82
|
+
username: user
|
83
|
+
password: secret
|
84
|
+
|
85
|
+
or you can use Oracle specific format in `database` parameter:
|
86
|
+
|
87
|
+
development:
|
88
|
+
adapter: oracle_enhanced
|
89
|
+
database: //localhost:1521/xe
|
90
|
+
username: user
|
91
|
+
password: secret
|
92
|
+
|
93
|
+
or you can even use Oracle specific TNS connection description:
|
94
|
+
|
95
|
+
development:
|
96
|
+
adapter: oracle_enhanced
|
97
|
+
database: "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=xe)))"
|
98
|
+
username: user
|
99
|
+
password: secret
|
100
|
+
|
101
|
+
If you deploy JRuby on Rails application in Java application server that supports JNDI connections then you can specify JNDI connection as well:
|
102
|
+
|
103
|
+
development:
|
104
|
+
adapter: oracle_enhanced
|
105
|
+
jndi: "jdbc/jndi_connection_name"
|
106
|
+
|
107
|
+
You can find other available database.yml connection parameters in [oracle_enhanced_adapter.rb](/rsim/oracle-enhanced/blob/master/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb). There are many NLS settings as well as some other Oracle session settings.
|
108
|
+
|
109
|
+
### Adapter settings
|
110
|
+
|
111
|
+
If you want to change Oracle enhanced adapter default settings then create initializer file e.g. `config/initializers/oracle.rb` specify there necessary defaults, e.g.:
|
112
|
+
|
113
|
+
# It is recommended to set time zone in TZ environment variable so that the same timezone will be used by Ruby and by Oracle session
|
114
|
+
ENV['TZ'] = 'UTC'
|
115
|
+
|
116
|
+
ActiveSupport.on_load(:active_record) do
|
117
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.class_eval do
|
118
|
+
# id columns and columns which end with _id will always be converted to integers
|
119
|
+
self.emulate_integers_by_column_name = true
|
120
|
+
# DATE columns which include "date" in name will be converted to Date, otherwise to Time
|
121
|
+
self.emulate_dates_by_column_name = true
|
122
|
+
# true and false will be stored as 'Y' and 'N'
|
123
|
+
self.emulate_booleans_from_strings = true
|
124
|
+
# start primary key sequences from 1 (and not 10000) and take just one next value in each session
|
125
|
+
self.default_sequence_start_value = "1 NOCACHE INCREMENT BY 1"
|
126
|
+
# other settings ...
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
In case of Rails 2 application you do not need to use `ActiveSupport.on_load(:active_record) do ... end` around settings code block.
|
131
|
+
|
132
|
+
See other adapter settings in [oracle_enhanced_adapter.rb](/rsim/oracle-enhanced/blob/master/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb).
|
133
|
+
|
134
|
+
### Legacy schema support
|
135
|
+
|
136
|
+
If you want to put Oracle enhanced adapter on top of existing schema tables then there are several methods how to override ActiveRecord defaults, see example:
|
137
|
+
|
138
|
+
class Employee < ActiveRecord::Base
|
139
|
+
# specify schema and table name
|
140
|
+
set_table_name "hr.hr_employees"
|
141
|
+
# specify primary key name
|
142
|
+
set_primary_key "employee_id"
|
143
|
+
# specify sequence name
|
144
|
+
set_sequence_name "hr.hr_employee_s"
|
145
|
+
# set which DATE columns should be converted to Ruby Date
|
146
|
+
set_date_columns :hired_on, :birth_date_on
|
147
|
+
# set which DATE columns should be converted to Ruby Time
|
148
|
+
set_datetime_columns :last_login_time
|
149
|
+
# set which VARCHAR2 columns should be converted to true and false
|
150
|
+
set_boolean_columns :manager, :active
|
151
|
+
# set which columns should be ignored in ActiveRecord
|
152
|
+
ignore_table_columns :attribute1, :attribute2
|
153
|
+
end
|
154
|
+
|
155
|
+
You can also access remote tables over database link using
|
156
|
+
|
157
|
+
set_table_name "hr_employees@db_link"
|
158
|
+
|
159
|
+
### Custom create, update and delete methods
|
160
|
+
|
161
|
+
If you have legacy schema and you are not allowed to do direct INSERTs, UPDATEs and DELETEs in legacy schema tables and need to use existing PL/SQL procedures for create, updated, delete operations then you should add `ruby-plsql` gem to your application and then define custom create, update and delete methods, see example:
|
162
|
+
|
163
|
+
class Employee < ActiveRecord::Base
|
164
|
+
# when defining create method then return ID of new record that will be assigned to id attribute of new object
|
165
|
+
set_create_method do
|
166
|
+
plsql.employees_pkg.create_employee(
|
167
|
+
:p_first_name => first_name,
|
168
|
+
:p_last_name => last_name,
|
169
|
+
:p_employee_id => nil
|
170
|
+
)[:p_employee_id]
|
171
|
+
end
|
172
|
+
set_update_method do
|
173
|
+
plsql.employees_pkg.update_employee(
|
174
|
+
:p_employee_id => id,
|
175
|
+
:p_first_name => first_name,
|
176
|
+
:p_last_name => last_name
|
177
|
+
)
|
178
|
+
end
|
179
|
+
set_delete_method do
|
180
|
+
plsql.employees_pkg.delete_employee(
|
181
|
+
:p_employee_id => id
|
182
|
+
)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
In addition in `config/initializers/oracle.rb` initializer specify that ruby-plsql should use ActiveRecord database connection:
|
187
|
+
|
188
|
+
plsql.activerecord_class = ActiveRecord::Base
|
189
|
+
|
190
|
+
### Oracle CONTEXT index support
|
191
|
+
|
192
|
+
Every edition of Oracle database includes [Oracle Text](http://www.oracle.com/technology/products/text/index.html) option for free which provides several full text indexing capabilities. Therefore in Oracle database case you don’t need external full text indexing and searching engines which can simplify your application deployment architecture.
|
193
|
+
|
194
|
+
To create simple single column index create migration with, e.g.
|
195
|
+
|
196
|
+
add_context_index :posts, :title
|
197
|
+
|
198
|
+
and you can remove context index with
|
199
|
+
|
200
|
+
remove_context_index :posts, :title
|
201
|
+
|
202
|
+
Include in class definition
|
203
|
+
|
204
|
+
has_context_index
|
205
|
+
|
206
|
+
and then you can do full text search with
|
207
|
+
|
208
|
+
Post.contains(:title, 'word')
|
209
|
+
|
210
|
+
You can create index on several columns (which will generate additional stored procedure for providing XML document with specified columns to indexer):
|
211
|
+
|
212
|
+
add_context_index :posts, [:title, :body]
|
213
|
+
|
214
|
+
And you can search either in all columns or specify in which column you want to search (as first argument you need to specify first column name as this is the column which is referenced during index creation):
|
215
|
+
|
216
|
+
Post.contains(:title, 'word')
|
217
|
+
Post.contains(:title, 'word within title')
|
218
|
+
Post.contains(:title, 'word within body')
|
219
|
+
|
220
|
+
See Oracle Text documentation for syntax that you can use in CONTAINS function in SELECT WHERE clause.
|
221
|
+
|
222
|
+
You can also specify some dummy main column name when creating multiple column index as well as specify to update index automatically after each commit (as otherwise you need to synchronize index manually or schedule periodic update):
|
223
|
+
|
224
|
+
add_context_index :posts, [:title, :body], :index_column => :all_text, :sync => 'ON COMMIT'
|
225
|
+
|
226
|
+
Post.contains(:all_text, 'word')
|
227
|
+
|
228
|
+
Or you can specify that index should be updated when specified columns are updated (e.g. in ActiveRecord you can specify to trigger index update when created_at or updated_at columns are updated). Otherwise index is updated only when main index column is updated.
|
229
|
+
|
230
|
+
add_context_index :posts, [:title, :body], :index_column => :all_text,
|
231
|
+
:sync => 'ON COMMIT', :index_column_trigger_on => [:created_at, :updated_at]
|
232
|
+
|
233
|
+
And you can even create index on multiple tables by providing SELECT statements which should be used to fetch necessary columns from related tables:
|
234
|
+
|
235
|
+
add_context_index :posts,
|
236
|
+
[:title, :body,
|
237
|
+
# specify aliases always with AS keyword
|
238
|
+
"SELECT comments.author AS comment_author, comments.body AS comment_body FROM comments WHERE comments.post_id = :id"
|
239
|
+
],
|
240
|
+
:name => 'post_and_comments_index',
|
241
|
+
:index_column => :all_text,
|
242
|
+
:index_column_trigger_on => [:updated_at, :comments_count],
|
243
|
+
:sync => 'ON COMMIT'
|
244
|
+
|
245
|
+
# search in any table columns
|
246
|
+
Post.contains(:all_text, 'word')
|
247
|
+
# search in specified column
|
248
|
+
Post.contains(:all_text, "aaa within title")
|
249
|
+
Post.contains(:all_text, "bbb within comment_author")
|
250
|
+
|
251
|
+
### Oracle specific schema statements and data types
|
252
|
+
|
253
|
+
There are several additional schema statements and data types available that you can use in database migrations:
|
254
|
+
|
255
|
+
* `add_foreign_key` and `remove_foreign_key` for foreign key definition (and they are also dumped in `db/schema.rb`)
|
256
|
+
* `add_synonym` and `remove_synonym` for synonym definition (and they are also dumped in `db/schema.rb`)
|
257
|
+
* You can create table with primary key trigger using `:primary_key_trigger => true` option for `create_table`
|
258
|
+
* You can define columns with `raw` type which maps to Oracle's `RAW` type
|
259
|
+
* You can add table and column comments with `:comment` option
|
260
|
+
* On Oracle 11g you can define `virtual` columns with calculation formula in `:default` option
|
261
|
+
* Default tablespaces can be specified for tables, indexes, clobs and blobs, for example:
|
262
|
+
|
263
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces =
|
264
|
+
{:clob => 'TS_LOB', :blob => 'TS_LOB', :index => 'TS_INDEX', :table => 'TS_DATA'}
|
265
|
+
|
266
|
+
TROUBLESHOOTING
|
267
|
+
---------------
|
268
|
+
|
269
|
+
### What to do if Oracle enhanced adapter is not working?
|
270
|
+
|
271
|
+
Please verify that
|
272
|
+
|
273
|
+
1. Oracle Instant Client is installed correctly
|
274
|
+
Can you connect to database using sqlnet?
|
275
|
+
|
276
|
+
2. ruby-oci8 is installed correctly
|
277
|
+
Try something like:
|
278
|
+
|
279
|
+
ruby -rubygems -e "require 'oci8'; OCI8.new('username','password','database').exec('select * from dual') do |r| puts r.join(','); end"
|
280
|
+
|
281
|
+
to verify that ruby-oci8 is working
|
282
|
+
|
283
|
+
3. Verify that activerecord-oracle_enhanced-adapter is working from irb
|
284
|
+
|
285
|
+
require 'rubygems'
|
286
|
+
gem 'activerecord'
|
287
|
+
gem 'activerecord-oracle_enhanced-adapter'
|
288
|
+
require 'activerecord'
|
289
|
+
ActiveRecord::Base.establish_connection(:adapter => "oracle_enhanced", :database => "database",:username => "user",:password => "password")
|
290
|
+
|
291
|
+
and see if it is successful (use your correct database, username and password)
|
292
|
+
|
293
|
+
### What to do if Oracle enhanced adapter is not working with Phusion Passenger?
|
294
|
+
|
295
|
+
Oracle Instant Client and ruby-oci8 requires that several environment variables are set:
|
296
|
+
|
297
|
+
* `LD_LIBRARY_PATH` (on Linux) or `DYLD_LIBRARY_PATH` (on Mac) should point to Oracle Instant Client directory (where Oracle client shared libraries are located)
|
298
|
+
* `TNS_ADMIN` should point to directory where `tnsnames.ora` file is located
|
299
|
+
* `NLS_LANG` should specify which territory and language NLS settings to use and which character set to use (e.g. `"AMERICAN_AMERICA.UTF8"`)
|
300
|
+
|
301
|
+
If this continues to throw "OCI Library Initialization Error (OCIError)", you might also need
|
302
|
+
|
303
|
+
* `ORACLE_HOME` set to full Oracle client installation directory
|
304
|
+
|
305
|
+
When Apache with Phusion Passenger (mod_passenger or previously mod_rails) is used for Rails application deployment then by default Ruby is launched without environment variables that you have set in shell profile scripts (e.g. .profile). Therefore it is necessary to set environment variables in one of the following ways:
|
306
|
+
|
307
|
+
* Create wrapper script as described in [Phusion blog](http://blog.phusion.nl/2008/12/16/passing-environment-variables-to-ruby-from-phusion-passenger) or [RayApps::Blog](http://blog.rayapps.com/2008/05/21/using-mod_rails-with-rails-applications-on-oracle)
|
308
|
+
* Set environment variables in the file which is used by Apache before launching Apache worker processes - on Linux it typically is envvars file (look in apachectl or apache2ctl script where it is looking for envvars file) or /System/Library/LaunchDaemons/org.apache.httpd.plist on Mac OS X. See the following [discussion thread](http://groups.google.com/group/oracle-enhanced/browse_thread/thread/c5f64106569fadd0) for more hints.
|
309
|
+
|
310
|
+
RUNNING TESTS
|
311
|
+
-------------
|
312
|
+
|
313
|
+
See [RUNNING_TESTS.md](/rsim/oracle-enhanced/blob/master/RUNNING_TESTS.md) for information how to set up environment and run Oracle enhanced adapter unit tests.
|
314
|
+
|
315
|
+
LINKS
|
316
|
+
-----
|
317
|
+
|
318
|
+
* Source code: http://github.com/rsim/oracle-enhanced
|
319
|
+
* Bug reports / Feature requests / Pull requests: http://github.com/rsim/oracle-enhanced/issues
|
320
|
+
* Discuss at Oracle enhanced adapter group: http://groups.google.com/group/oracle-enhanced
|
321
|
+
* Blog posts about Oracle enhanced adapter can be found at http://blog.rayapps.com/category/oracle_enhanced
|
322
|
+
|
323
|
+
CONTRIBUTORS
|
324
|
+
------------
|
325
|
+
|
326
|
+
* Raimonds Simanovskis
|
327
|
+
* Jorge Dias
|
328
|
+
* James Wylder
|
329
|
+
* Rob Christie
|
330
|
+
* Nate Wieger
|
331
|
+
* Edgars Beigarts
|
332
|
+
* Lachlan Laycock
|
333
|
+
* toddwf
|
334
|
+
* Anton Jenkins
|
335
|
+
* Dave Smylie
|
336
|
+
* Alex Rothenberg
|
337
|
+
* Billy Reisinger
|
338
|
+
* David Blain
|
339
|
+
* Joe Khoobyar
|
340
|
+
* Edvard Majakari
|
341
|
+
* Beau Fabry
|
342
|
+
* Simon Chiang
|
343
|
+
* Peter Nyberg
|
344
|
+
* Dwayne Litzenberger
|
345
|
+
* Aaron Patterson
|
346
|
+
* Darcy Schultz
|
347
|
+
* Alexi Rahman
|
348
|
+
* Joeri Samson
|
349
|
+
* Luca Bernardo Ciddio
|
350
|
+
* Sam Baskinger
|
351
|
+
* Benjamin Ortega
|
352
|
+
* Yasuo Honda
|
353
|
+
|
354
|
+
LICENSE
|
355
|
+
-------
|
356
|
+
|
357
|
+
(The MIT License)
|
358
|
+
|
359
|
+
Copyright (c) 2008-2011 Graham Jenkins, Michael Schoen, Raimonds Simanovskis
|
360
|
+
|
361
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
362
|
+
a copy of this software and associated documentation files (the
|
363
|
+
'Software'), to deal in the Software without restriction, including
|
364
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
365
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
366
|
+
permit persons to whom the Software is furnished to do so, subject to
|
367
|
+
the following conditions:
|
368
|
+
|
369
|
+
The above copyright notice and this permission notice shall be
|
370
|
+
included in all copies or substantial portions of the Software.
|
371
|
+
|
372
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
373
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
374
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
375
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
376
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
377
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
378
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/RUNNING_TESTS.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
Creating the test database
|
2
|
+
--------------------------
|
3
|
+
|
4
|
+
You need Oracle database (version 10.2 or later) with SYS and SYSTEM user access.
|
5
|
+
|
6
|
+
If you are on a Mac OS X 10.6 then use [these instructions](http://blog.rayapps.com/2009/09/14/how-to-install-oracle-database-10g-on-mac-os-x-snow-leopard) to install local Oracle DB 10.2.0.4. Other option is to use Linux VM and install Oracle DB on it.
|
7
|
+
|
8
|
+
If you are on Linux (or will use Linux virtual machine) and need Oracle DB just for running tests then Oracle DB XE edition is enough. See [Oracle XE downloads page](http://www.oracle.com/technetwork/database/express-edition/downloads/index.html) for download links and instructions.
|
9
|
+
|
10
|
+
If you are getting ORA-12520 errors when running tests then it means that Oracle cannot create enough processes to handle many connections (as during tests many connections are created and destroyed). In this case you need to log in as SYSTEM user and execute e.g.
|
11
|
+
|
12
|
+
alter system set processes=200 scope=spfile;
|
13
|
+
|
14
|
+
to increase process limit and then restart the database (this will be necessary if Oracle XE will be used as default processes limit is 40).
|
15
|
+
|
16
|
+
Ruby versions
|
17
|
+
-------------
|
18
|
+
|
19
|
+
It is recommended to use [RVM](http://rvm.beginrescueend.com) to run tests with different Ruby implementations. oracle_enhanced is mainly tested with MRI 1.8.7 (all Rails versions) and 1.9.2 (Rails 3) and JRuby 1.6.
|
20
|
+
|
21
|
+
Running tests
|
22
|
+
-------------
|
23
|
+
|
24
|
+
* Create Oracle database schema for test purposes. Review `spec/spec_helper.rb` to see default schema/user names and database names (use environment variables to override defaults)
|
25
|
+
|
26
|
+
SQL> CREATE USER oracle_enhanced IDENTIFIED BY oracle_enhanced;
|
27
|
+
SQL> GRANT unlimited tablespace, create session, create table, create sequence, create procedure, create trigger, create view, create materialized view, create database link, create synonym, create type, ctxapp TO oracle_enhanced;
|
28
|
+
|
29
|
+
* If you use RVM then switch to corresponding Ruby (1.8.7, 1.9.2 or JRuby) and it is recommended to create isolated gemset for test purposes (e.g. rvm create gemset oracle_enhanced)
|
30
|
+
|
31
|
+
* Install bundler with
|
32
|
+
|
33
|
+
gem install bundler
|
34
|
+
|
35
|
+
* Set RAILS_GEM_VERSION to Rails version that you would like to use in oracle_enhanced tests, e.g.
|
36
|
+
|
37
|
+
export RAILS_GEM_VERSION=3.0.3
|
38
|
+
|
39
|
+
* Install necessary gems with
|
40
|
+
|
41
|
+
bundle install
|
42
|
+
|
43
|
+
* Run tests with
|
44
|
+
|
45
|
+
rake spec
|