activerecord-oracle_enhanced-adapter 1.4.3 → 1.5.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -14
  3. data/History.md +51 -0
  4. data/README.md +32 -1
  5. data/VERSION +1 -1
  6. data/activerecord-oracle_enhanced-adapter.gemspec +2 -4
  7. data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +315 -57
  8. data/lib/active_record/connection_adapters/oracle_enhanced_column_dumper.rb +55 -0
  9. data/lib/active_record/connection_adapters/oracle_enhanced_context_index.rb +4 -13
  10. data/lib/active_record/connection_adapters/oracle_enhanced_dirty.rb +5 -6
  11. data/lib/active_record/connection_adapters/oracle_enhanced_jdbc_connection.rb +19 -11
  12. data/lib/active_record/connection_adapters/oracle_enhanced_procedures.rb +163 -232
  13. data/lib/active_record/connection_adapters/oracle_enhanced_schema_definitions.rb +18 -10
  14. data/lib/active_record/connection_adapters/oracle_enhanced_schema_dumper.rb +20 -32
  15. data/lib/active_record/connection_adapters/oracle_enhanced_schema_statements.rb +54 -35
  16. data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +5 -74
  17. data/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb +3 -2
  18. data/spec/active_record/connection_adapters/oracle_enhanced_context_index_spec.rb +98 -98
  19. data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +5 -1
  20. data/spec/active_record/connection_adapters/oracle_enhanced_dbms_output_spec.rb +3 -3
  21. data/spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb +11 -5
  22. data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +56 -55
  23. data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +15 -8
  24. data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +4 -3
  25. data/spec/spec_helper.rb +25 -54
  26. metadata +32 -20
  27. data/lib/active_record/connection_adapters/oracle_enhanced_activerecord_patches.rb +0 -41
  28. data/lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb +0 -121
  29. data/lib/active_record/connection_adapters/oracle_enhanced_tasks.rb +0 -17
@@ -92,7 +92,8 @@ describe "OracleEnhancedConnection" do
92
92
 
93
93
  it "should create new connection using :url" do
94
94
  params = CONNECTION_PARAMS.dup
95
- params[:url] = "jdbc:oracle:thin:@#{DATABASE_HOST && "#{DATABASE_HOST}:"}#{DATABASE_PORT && "#{DATABASE_PORT}:"}#{DATABASE_NAME}"
95
+ params[:url] = "jdbc:oracle:thin:@#{DATABASE_HOST && "//#{DATABASE_HOST}#{DATABASE_PORT && ":#{DATABASE_PORT}"}/"}#{DATABASE_NAME}"
96
+
96
97
  params[:host] = nil
97
98
  params[:database] = nil
98
99
  @conn = ActiveRecord::ConnectionAdapters::OracleEnhancedConnection.create(params)
@@ -157,7 +158,7 @@ describe "OracleEnhancedConnection" do
157
158
 
158
159
  it "should fall back to directly instantiating OracleDriver" do
159
160
  params = CONNECTION_PARAMS.dup
160
- params[:url] = "jdbc:oracle:thin:@#{DATABASE_HOST && "#{DATABASE_HOST}:"}#{DATABASE_PORT && "#{DATABASE_PORT}:"}#{DATABASE_NAME}"
161
+ params[:url] = "jdbc:oracle:thin:@#{DATABASE_HOST && "//#{DATABASE_HOST}#{DATABASE_PORT && ":#{DATABASE_PORT}"}/"}#{DATABASE_NAME}"
161
162
  params[:host] = nil
162
163
  params[:database] = nil
163
164
  java.sql.DriverManager.stub!(:getConnection).and_raise('no suitable driver found')
@@ -7,19 +7,19 @@ describe "OracleEnhancedAdapter context index" do
7
7
 
8
8
  def create_table_posts
9
9
  schema_define do
10
- create_table :posts, :force => true do |t|
10
+ create_table :posts, force: true do |t|
11
11
  t.string :title
12
12
  t.text :body
13
13
  t.integer :comments_count
14
14
  t.timestamps
15
- t.string :all_text, :limit => 2 # will be used for multi-column index
15
+ t.string :all_text, limit: 2 # will be used for multi-column index
16
16
  end
17
17
  end
18
18
  end
19
19
 
20
20
  def create_table_comments
21
21
  schema_define do
22
- create_table :comments, :force => true do |t|
22
+ create_table :comments, force: true do |t|
23
23
  t.integer :post_id
24
24
  t.string :author
25
25
  t.text :body
@@ -68,11 +68,11 @@ describe "OracleEnhancedAdapter context index" do
68
68
  class ::Post < ActiveRecord::Base
69
69
  has_context_index
70
70
  end
71
- @post0 = Post.create(:title => "dummy title", :body => "dummy body")
72
- @post1 = Post.create(:title => @title_words.join(' '), :body => @body_words.join(' '))
73
- @post2 = Post.create(:title => (@title_words*2).join(' '), :body => (@body_words*2).join(' '))
74
- @post_with_null_body = Post.create(:title => "withnull", :body => nil)
75
- @post_with_null_title = Post.create(:title => nil, :body => "withnull")
71
+ @post0 = Post.create(title: "dummy title", body: "dummy body")
72
+ @post1 = Post.create(title: @title_words.join(' '), body: @body_words.join(' '))
73
+ @post2 = Post.create(title: (@title_words*2).join(' '), body: (@body_words*2).join(' '))
74
+ @post_with_null_body = Post.create(title: "withnull", body: nil)
75
+ @post_with_null_title = Post.create(title: nil, body: "withnull")
76
76
  end
77
77
 
78
78
  after(:all) do
@@ -88,7 +88,7 @@ describe "OracleEnhancedAdapter context index" do
88
88
  it "should create single VARCHAR2 column index" do
89
89
  @conn.add_context_index :posts, :title
90
90
  @title_words.each do |word|
91
- Post.contains(:title, word).all.should == [@post2, @post1]
91
+ Post.contains(:title, word).to_a.should == [@post2, @post1]
92
92
  end
93
93
  @conn.remove_context_index :posts, :title
94
94
  end
@@ -96,7 +96,7 @@ describe "OracleEnhancedAdapter context index" do
96
96
  it "should create single CLOB column index" do
97
97
  @conn.add_context_index :posts, :body
98
98
  @body_words.each do |word|
99
- Post.contains(:body, word).all.should == [@post2, @post1]
99
+ Post.contains(:body, word).to_a.should == [@post2, @post1]
100
100
  end
101
101
  @conn.remove_context_index :posts, :body
102
102
  end
@@ -110,62 +110,62 @@ describe "OracleEnhancedAdapter context index" do
110
110
  it "should create multiple column index" do
111
111
  @conn.add_context_index :posts, [:title, :body]
112
112
  (@title_words+@body_words).each do |word|
113
- Post.contains(:title, word).all.should == [@post2, @post1]
113
+ Post.contains(:title, word).to_a.should == [@post2, @post1]
114
114
  end
115
115
  @conn.remove_context_index :posts, [:title, :body]
116
116
  end
117
117
 
118
118
  it "should index records with null values" do
119
119
  @conn.add_context_index :posts, [:title, :body]
120
- Post.contains(:title, "withnull").all.should == [@post_with_null_body, @post_with_null_title]
120
+ Post.contains(:title, "withnull").to_a.should == [@post_with_null_body, @post_with_null_title]
121
121
  @conn.remove_context_index :posts, [:title, :body]
122
122
  end
123
123
 
124
124
  it "should create multiple column index with specified main index column" do
125
125
  @conn.add_context_index :posts, [:title, :body],
126
- :index_column => :all_text, :sync => 'ON COMMIT'
127
- @post = Post.create(:title => "abc", :body => "def")
128
- Post.contains(:all_text, "abc").all.should == [@post]
129
- Post.contains(:all_text, "def").all.should == [@post]
130
- @post.update_attributes!(:title => "ghi")
126
+ index_column: :all_text, sync: 'ON COMMIT'
127
+ @post = Post.create(title: "abc", body: "def")
128
+ Post.contains(:all_text, "abc").to_a.should == [@post]
129
+ Post.contains(:all_text, "def").to_a.should == [@post]
130
+ @post.update_attributes!(title: "ghi")
131
131
  # index will not be updated as all_text column is not changed
132
- Post.contains(:all_text, "ghi").all.should be_empty
133
- @post.update_attributes!(:all_text => "1")
132
+ Post.contains(:all_text, "ghi").to_a.should be_empty
133
+ @post.update_attributes!(all_text: "1")
134
134
  # index will be updated when all_text column is changed
135
- Post.contains(:all_text, "ghi").all.should == [@post]
136
- @conn.remove_context_index :posts, :index_column => :all_text
135
+ Post.contains(:all_text, "ghi").to_a.should == [@post]
136
+ @conn.remove_context_index :posts, index_column: :all_text
137
137
  end
138
138
 
139
139
  it "should create multiple column index with trigger updated main index column" do
140
140
  @conn.add_context_index :posts, [:title, :body],
141
- :index_column => :all_text, :index_column_trigger_on => [:created_at, :updated_at],
142
- :sync => 'ON COMMIT'
143
- @post = Post.create(:title => "abc", :body => "def")
144
- Post.contains(:all_text, "abc").all.should == [@post]
145
- Post.contains(:all_text, "def").all.should == [@post]
146
- @post.update_attributes!(:title => "ghi")
141
+ index_column: :all_text, index_column_trigger_on: [:created_at, :updated_at],
142
+ sync: 'ON COMMIT'
143
+ @post = Post.create(title: "abc", body: "def")
144
+ Post.contains(:all_text, "abc").to_a.should == [@post]
145
+ Post.contains(:all_text, "def").to_a.should == [@post]
146
+ @post.update_attributes!(title: "ghi")
147
147
  # index should be updated as created_at column is changed
148
- Post.contains(:all_text, "ghi").all.should == [@post]
149
- @conn.remove_context_index :posts, :index_column => :all_text
148
+ Post.contains(:all_text, "ghi").to_a.should == [@post]
149
+ @conn.remove_context_index :posts, index_column: :all_text
150
150
  end
151
151
 
152
152
  it "should use base letter conversion with BASIC_LEXER" do
153
- @post = Post.create!(:title => "āčē", :body => "dummy")
153
+ @post = Post.create!(title: "āčē", body: "dummy")
154
154
  @conn.add_context_index :posts, :title,
155
- :lexer => { :type => "BASIC_LEXER", :base_letter_type => 'GENERIC', :base_letter => true }
156
- Post.contains(:title, "āčē").all.should == [@post]
157
- Post.contains(:title, "ace").all.should == [@post]
158
- Post.contains(:title, "ACE").all.should == [@post]
155
+ lexer: { type: "BASIC_LEXER", base_letter_type: 'GENERIC', base_letter: true }
156
+ Post.contains(:title, "āčē").to_a.should == [@post]
157
+ Post.contains(:title, "ace").to_a.should == [@post]
158
+ Post.contains(:title, "ACE").to_a.should == [@post]
159
159
  @conn.remove_context_index :posts, :title
160
160
  end
161
161
 
162
162
  it "should create transactional index and sync index within transaction on inserts and updates" do
163
- @conn.add_context_index :posts, :title, :transactional => true
163
+ @conn.add_context_index :posts, :title, transactional: true
164
164
  Post.transaction do
165
- @post = Post.create(:title => "abc")
166
- Post.contains(:title, "abc").all.should == [@post]
167
- @post.update_attributes!(:title => "ghi")
168
- Post.contains(:title, "ghi").all.should == [@post]
165
+ @post = Post.create(title: "abc")
166
+ Post.contains(:title, "abc").to_a.should == [@post]
167
+ @post.update_attributes!(title: "ghi")
168
+ Post.contains(:title, "ghi").to_a.should == [@post]
169
169
  end
170
170
  @conn.remove_context_index :posts, :title
171
171
  end
@@ -176,11 +176,11 @@ describe "OracleEnhancedAdapter context index" do
176
176
  @conn = ActiveRecord::Base.connection
177
177
  create_tables
178
178
  class ::Post < ActiveRecord::Base
179
- has_many :comments, :dependent => :destroy
179
+ has_many :comments, dependent: :destroy
180
180
  has_context_index
181
181
  end
182
182
  class ::Comment < ActiveRecord::Base
183
- belongs_to :post, :counter_cache => true
183
+ belongs_to :post, counter_cache: true
184
184
  end
185
185
  end
186
186
 
@@ -201,16 +201,16 @@ describe "OracleEnhancedAdapter context index" do
201
201
  # specify aliases always with AS keyword
202
202
  "SELECT comments.author AS comment_author, comments.body AS comment_body FROM comments WHERE comments.post_id = :id"
203
203
  ],
204
- :name => 'post_and_comments_index',
205
- :index_column => :all_text, :index_column_trigger_on => [:updated_at, :comments_count],
206
- :sync => 'ON COMMIT'
207
- @post = Post.create!(:title => "aaa", :body => "bbb")
208
- @post.comments.create!(:author => "ccc", :body => "ddd")
209
- @post.comments.create!(:author => "eee", :body => "fff")
204
+ name: 'post_and_comments_index',
205
+ index_column: :all_text, index_column_trigger_on: [:updated_at, :comments_count],
206
+ sync: 'ON COMMIT'
207
+ @post = Post.create!(title: "aaa", body: "bbb")
208
+ @post.comments.create!(author: "ccc", body: "ddd")
209
+ @post.comments.create!(author: "eee", body: "fff")
210
210
  ["aaa", "bbb", "ccc", "ddd", "eee", "fff"].each do |word|
211
- Post.contains(:all_text, word).all.should == [@post]
211
+ Post.contains(:all_text, word).to_a.should == [@post]
212
212
  end
213
- @conn.remove_context_index :posts, :name => 'post_and_comments_index'
213
+ @conn.remove_context_index :posts, name: 'post_and_comments_index'
214
214
  end
215
215
 
216
216
  it "should create multiple table index with specified main index column (when subquery has newlines)" do
@@ -223,36 +223,36 @@ describe "OracleEnhancedAdapter context index" do
223
223
  FROM comments
224
224
  WHERE comments.post_id = :id }
225
225
  ],
226
- :name => 'post_and_comments_index',
227
- :index_column => :all_text, :index_column_trigger_on => [:updated_at, :comments_count],
228
- :sync => 'ON COMMIT'
229
- @post = Post.create!(:title => "aaa", :body => "bbb")
230
- @post.comments.create!(:author => "ccc", :body => "ddd")
231
- @post.comments.create!(:author => "eee", :body => "fff")
226
+ name: 'post_and_comments_index',
227
+ index_column: :all_text, index_column_trigger_on: [:updated_at, :comments_count],
228
+ sync: 'ON COMMIT'
229
+ @post = Post.create!(title: "aaa", body: "bbb")
230
+ @post.comments.create!(author: "ccc", body: "ddd")
231
+ @post.comments.create!(author: "eee", body: "fff")
232
232
  ["aaa", "bbb", "ccc", "ddd", "eee", "fff"].each do |word|
233
- Post.contains(:all_text, word).all.should == [@post]
233
+ Post.contains(:all_text, word).to_a.should == [@post]
234
234
  end
235
- @conn.remove_context_index :posts, :name => 'post_and_comments_index'
235
+ @conn.remove_context_index :posts, name: 'post_and_comments_index'
236
236
  end
237
237
 
238
238
  it "should find by search term within specified field" do
239
- @post = Post.create!(:title => "aaa", :body => "bbb")
240
- @post.comments.create!(:author => "ccc", :body => "ddd")
239
+ @post = Post.create!(title: "aaa", body: "bbb")
240
+ @post.comments.create!(author: "ccc", body: "ddd")
241
241
  @conn.add_context_index :posts,
242
242
  [:title, :body,
243
243
  # specify aliases always with AS keyword
244
244
  "SELECT comments.author AS comment_author, comments.body AS comment_body FROM comments WHERE comments.post_id = :id"
245
245
  ],
246
- :index_column => :all_text
247
- Post.contains(:all_text, "aaa within title").all.should == [@post]
248
- Post.contains(:all_text, "aaa within body").all.should be_empty
249
- Post.contains(:all_text, "bbb within body").all.should == [@post]
250
- Post.contains(:all_text, "bbb within title").all.should be_empty
251
- Post.contains(:all_text, "ccc within comment_author").all.should == [@post]
252
- Post.contains(:all_text, "ccc within comment_body").all.should be_empty
253
- Post.contains(:all_text, "ddd within comment_body").all.should == [@post]
254
- Post.contains(:all_text, "ddd within comment_author").all.should be_empty
255
- @conn.remove_context_index :posts, :index_column => :all_text
246
+ index_column: :all_text
247
+ Post.contains(:all_text, "aaa within title").to_a.should == [@post]
248
+ Post.contains(:all_text, "aaa within body").to_a.should be_empty
249
+ Post.contains(:all_text, "bbb within body").to_a.should == [@post]
250
+ Post.contains(:all_text, "bbb within title").to_a.should be_empty
251
+ Post.contains(:all_text, "ccc within comment_author").to_a.should == [@post]
252
+ Post.contains(:all_text, "ccc within comment_body").to_a.should be_empty
253
+ Post.contains(:all_text, "ddd within comment_body").to_a.should == [@post]
254
+ Post.contains(:all_text, "ddd within comment_author").to_a.should be_empty
255
+ @conn.remove_context_index :posts, index_column: :all_text
256
256
  end
257
257
 
258
258
  end
@@ -264,7 +264,7 @@ describe "OracleEnhancedAdapter context index" do
264
264
  class ::Post < ActiveRecord::Base
265
265
  has_context_index
266
266
  end
267
- @post = Post.create(:title => 'aaa', :body => 'bbb')
267
+ @post = Post.create(title: 'aaa', body: 'bbb')
268
268
  @tablespace = @conn.default_tablespace
269
269
  set_logger
270
270
  @conn = ActiveRecord::Base.connection
@@ -288,17 +288,17 @@ describe "OracleEnhancedAdapter context index" do
288
288
  end
289
289
 
290
290
  it "should create index on single column" do
291
- @conn.add_context_index :posts, :title, :tablespace => @tablespace
291
+ @conn.add_context_index :posts, :title, tablespace: @tablespace
292
292
  verify_logged_statements
293
- Post.contains(:title, 'aaa').all.should == [@post]
293
+ Post.contains(:title, 'aaa').to_a.should == [@post]
294
294
  @conn.remove_context_index :posts, :title
295
295
  end
296
296
 
297
297
  it "should create index on multiple columns" do
298
- @conn.add_context_index :posts, [:title, :body], :name => 'index_posts_text', :tablespace => @conn.default_tablespace
298
+ @conn.add_context_index :posts, [:title, :body], name: 'index_posts_text', tablespace: @conn.default_tablespace
299
299
  verify_logged_statements
300
- Post.contains(:title, 'aaa AND bbb').all.should == [@post]
301
- @conn.remove_context_index :posts, :name => 'index_posts_text'
300
+ Post.contains(:title, 'aaa AND bbb').to_a.should == [@post]
301
+ @conn.remove_context_index :posts, name: 'index_posts_text'
302
302
  end
303
303
 
304
304
  end
@@ -325,7 +325,7 @@ describe "OracleEnhancedAdapter context index" do
325
325
 
326
326
  it "should dump definition of single column index" do
327
327
  @conn.add_context_index :posts, :title
328
- standard_dump.should =~ /add_context_index "posts", \["title"\], :name => \"index_posts_on_title\"$/
328
+ standard_dump.should =~ /add_context_index "posts", \["title"\], name: \"index_posts_on_title\"$/
329
329
  @conn.remove_context_index :posts, :title
330
330
  end
331
331
 
@@ -337,41 +337,41 @@ describe "OracleEnhancedAdapter context index" do
337
337
 
338
338
  it "should dump definition of multiple table index with options" do
339
339
  options = {
340
- :name => 'post_and_comments_index',
341
- :index_column => :all_text, :index_column_trigger_on => :updated_at,
342
- :transactional => true,
343
- :sync => 'ON COMMIT'
340
+ name: 'post_and_comments_index',
341
+ index_column: :all_text, index_column_trigger_on: :updated_at,
342
+ transactional: true,
343
+ sync: 'ON COMMIT'
344
344
  }
345
345
  sub_query = "SELECT comments.author AS comment_author, comments.body AS comment_body FROM comments WHERE comments.post_id = :id"
346
346
  @conn.add_context_index :posts, [:title, :body, sub_query], options
347
347
  standard_dump.should =~ /add_context_index "posts", \[:title, :body, "#{sub_query}"\], #{options.inspect[1..-2]}$/
348
- @conn.remove_context_index :posts, :name => 'post_and_comments_index'
348
+ @conn.remove_context_index :posts, name: 'post_and_comments_index'
349
349
  end
350
350
 
351
351
  it "should dump definition of multiple table index with options (when definition is larger than 4000 bytes)" do
352
352
  options = {
353
- :name => 'post_and_comments_index',
354
- :index_column => :all_text, :index_column_trigger_on => :updated_at,
355
- :transactional => true,
356
- :sync => 'ON COMMIT'
353
+ name: 'post_and_comments_index',
354
+ index_column: :all_text, index_column_trigger_on: :updated_at,
355
+ transactional: true,
356
+ sync: 'ON COMMIT'
357
357
  }
358
358
  sub_query = "SELECT comments.author AS comment_author, comments.body AS comment_body FROM comments WHERE comments.post_id = :id#{' AND 1=1' * 500}"
359
359
  @conn.add_context_index :posts, [:title, :body, sub_query], options
360
360
  standard_dump.should =~ /add_context_index "posts", \[:title, :body, "#{sub_query}"\], #{options.inspect[1..-2]}$/
361
- @conn.remove_context_index :posts, :name => 'post_and_comments_index'
361
+ @conn.remove_context_index :posts, name: 'post_and_comments_index'
362
362
  end
363
363
 
364
364
  it "should dump definition of multiple table index with options (when subquery has newlines)" do
365
365
  options = {
366
- :name => 'post_and_comments_index',
367
- :index_column => :all_text, :index_column_trigger_on => :updated_at,
368
- :transactional => true,
369
- :sync => 'ON COMMIT'
366
+ name: 'post_and_comments_index',
367
+ index_column: :all_text, index_column_trigger_on: :updated_at,
368
+ transactional: true,
369
+ sync: 'ON COMMIT'
370
370
  }
371
371
  sub_query = "SELECT comments.author AS comment_author, comments.body AS comment_body\nFROM comments\nWHERE comments.post_id = :id"
372
372
  @conn.add_context_index :posts, [:title, :body, sub_query], options
373
373
  standard_dump.should =~ /add_context_index "posts", \[:title, :body, "#{sub_query.gsub(/\n/, ' ')}"\], #{options.inspect[1..-2]}$/
374
- @conn.remove_context_index :posts, :name => 'post_and_comments_index'
374
+ @conn.remove_context_index :posts, name: 'post_and_comments_index'
375
375
  end
376
376
 
377
377
  end
@@ -391,7 +391,7 @@ describe "OracleEnhancedAdapter context index" do
391
391
 
392
392
  it "should dump definition of single column index" do
393
393
  schema_define { add_context_index :posts, :title }
394
- standard_dump.should =~ /add_context_index "posts", \["title"\], :name => "i_xxx_posts_xxx_title"$/
394
+ standard_dump.should =~ /add_context_index "posts", \["title"\], name: "i_xxx_posts_xxx_title"$/
395
395
  schema_define { remove_context_index :posts, :title }
396
396
  end
397
397
 
@@ -403,11 +403,11 @@ describe "OracleEnhancedAdapter context index" do
403
403
 
404
404
  it "should dump definition of multiple table index with options" do
405
405
  options = {
406
- :name => 'xxx_post_and_comments_i',
407
- :index_column => :all_text, :index_column_trigger_on => :updated_at,
408
- :lexer => { :type => "BASIC_LEXER", :base_letter_type => 'GENERIC', :base_letter => true },
409
- :wordlist => { :type => "BASIC_WORDLIST", :prefix_index => true },
410
- :sync => 'ON COMMIT'
406
+ name: 'xxx_post_and_comments_i',
407
+ index_column: :all_text, index_column_trigger_on: :updated_at,
408
+ lexer: { type: "BASIC_LEXER", base_letter_type: 'GENERIC', base_letter: true },
409
+ wordlist: { type: "BASIC_WORDLIST", prefix_index: true },
410
+ sync: 'ON COMMIT'
411
411
  }
412
412
  schema_define do
413
413
  add_context_index :posts,
@@ -417,7 +417,7 @@ describe "OracleEnhancedAdapter context index" do
417
417
  end
418
418
  standard_dump.should =~ /add_context_index "posts", \[:title, :body, "SELECT comments.author AS comment_author, comments.body AS comment_body FROM comments WHERE comments.post_id = :id"\], #{
419
419
  options.inspect[1..-2].gsub(/[{}]/){|s| '\\'<<s }}$/
420
- schema_define { remove_context_index :posts, :name => 'xxx_post_and_comments_i' }
420
+ schema_define { remove_context_index :posts, name: 'xxx_post_and_comments_i' }
421
421
  end
422
422
 
423
423
  end
@@ -918,7 +918,11 @@ describe "OracleEnhancedAdapter handling of CLOB columns" do
918
918
  serialize :comments
919
919
  end
920
920
  class ::TestEmployeeReadOnlyClob < ActiveRecord::Base
921
- set_table_name :test_employees
921
+ if self.respond_to?(:table_name=)
922
+ self.table_name = "test_employees"
923
+ else
924
+ set_table_name = "test_employees"
925
+ end
922
926
  attr_readonly :comments
923
927
  end
924
928
  end
@@ -42,7 +42,7 @@ describe "OracleEnhancedAdapter logging dbms_output from plsql" do
42
42
  it "should NOT log dbms output when dbms output is disabled" do
43
43
  @conn.disable_dbms_output
44
44
 
45
- @conn.select_all("select more_than_five_characters_long('hi there') is_it_long from dual").should == [{'is_it_long'=>1}]
45
+ @conn.select_all("select more_than_five_characters_long('hi there') is_it_long from dual").to_a.should == [{'is_it_long'=>1}]
46
46
 
47
47
  @logger.output(:debug).should_not match(/^DBMS_OUTPUT/)
48
48
  end
@@ -50,7 +50,7 @@ describe "OracleEnhancedAdapter logging dbms_output from plsql" do
50
50
  it "should log dbms output lines to the rails log" do
51
51
  @conn.enable_dbms_output
52
52
 
53
- @conn.select_all("select more_than_five_characters_long('hi there') is_it_long from dual").should == [{'is_it_long'=>1}]
53
+ @conn.select_all("select more_than_five_characters_long('hi there') is_it_long from dual").to_a.should == [{'is_it_long'=>1}]
54
54
 
55
55
  @logger.output(:debug).should match(/^DBMS_OUTPUT: before the if -hi there-$/)
56
56
  @logger.output(:debug).should match(/^DBMS_OUTPUT: it is longer than 5$/)
@@ -60,7 +60,7 @@ describe "OracleEnhancedAdapter logging dbms_output from plsql" do
60
60
  it "should log dbms output lines to the rails log" do
61
61
  @conn.enable_dbms_output
62
62
 
63
- @conn.select_all("select more_than_five_characters_long('short') is_it_long from dual").should == [{'is_it_long'=>0}]
63
+ @conn.select_all("select more_than_five_characters_long('short') is_it_long from dual").to_a.should == [{'is_it_long'=>0}]
64
64
 
65
65
  @logger.output(:debug).should match(/^DBMS_OUTPUT: before the if -short-$/)
66
66
  @logger.output(:debug).should match(/^DBMS_OUTPUT: it is 5 or shorter$/)
@@ -107,6 +107,8 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
107
107
 
108
108
  before(:each) do
109
109
  class ::TestEmployee < ActiveRecord::Base
110
+ include ActiveRecord::OracleEnhancedProcedures
111
+
110
112
  if self.respond_to?(:primary_key=)
111
113
  self.primary_key = :employee_id
112
114
  else
@@ -226,9 +228,9 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
226
228
  @employee.first_name.should == "First"
227
229
  end
228
230
 
229
- it "should not update record if nothing is changed and partial updates are enabled" do
231
+ it "should not update record if nothing is changed and partial writes are enabled" do
230
232
  return pending("Not in this ActiveRecord version") unless TestEmployee.respond_to?(:partial_updates=)
231
- TestEmployee.partial_updates = true
233
+ TestEmployee.partial_writes = true
232
234
  @employee = TestEmployee.create(
233
235
  :first_name => "First",
234
236
  :last_name => "Last",
@@ -240,9 +242,9 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
240
242
  @employee.version.should == 1
241
243
  end
242
244
 
243
- it "should update record if nothing is changed and partial updates are disabled" do
245
+ it "should update record if nothing is changed and partial writes are disabled" do
244
246
  return pending("Not in this ActiveRecord version") unless TestEmployee.respond_to?(:partial_updates=)
245
- TestEmployee.partial_updates = false
247
+ TestEmployee.partial_writes = false
246
248
  @employee = TestEmployee.create(
247
249
  :first_name => "First",
248
250
  :last_name => "Last",
@@ -295,6 +297,7 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
295
297
  }.should raise_error("Make the transaction rollback")
296
298
  @employee.id.should == empl_id
297
299
  TestEmployee.find_by_employee_id(empl_id).should_not be_nil
300
+ clear_logger
298
301
  end
299
302
 
300
303
  it "should set timestamps when creating record" do
@@ -330,10 +333,11 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
330
333
  :hire_date => @today
331
334
  )
332
335
  @logger.logged(:debug).last.should match(/^TestEmployee Create \(\d+\.\d+(ms)?\) custom create method$/)
336
+ clear_logger
333
337
  end
334
338
 
335
339
  it "should log update record" do
336
- (TestEmployee.partial_updates = false) rescue nil
340
+ (TestEmployee.partial_writes = false) rescue nil
337
341
  @employee = TestEmployee.create(
338
342
  :first_name => "First",
339
343
  :last_name => "Last",
@@ -342,6 +346,7 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
342
346
  set_logger
343
347
  @employee.save!
344
348
  @logger.logged(:debug).last.should match(/^TestEmployee Update \(\d+\.\d+(ms)?\) custom update method with employee_id=#{@employee.id}$/)
349
+ clear_logger
345
350
  end
346
351
 
347
352
  it "should log delete record" do
@@ -353,6 +358,7 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
353
358
  set_logger
354
359
  @employee.destroy
355
360
  @logger.logged(:debug).last.should match(/^TestEmployee Destroy \(\d+\.\d+(ms)?\) custom delete method with employee_id=#{@employee.id}$/)
361
+ clear_logger
356
362
  end
357
363
 
358
364
  it "should validate new record before creation" do