Git Product home page Git Product logo

oracle-enhanced's People

Contributors

akostadinov avatar basking2 avatar cdinger avatar chriger avatar dabla avatar ebeigarts avatar jbotelho2-bb avatar joekhoobyar avatar josecoelho avatar joshpencheon avatar kamipo avatar kennyj avatar koic avatar kubo avatar matthewd avatar mkurkov avatar nhance avatar openface avatar rammpeter avatar riyengar8 avatar rsim avatar rwc9u avatar rypit avatar sanelson2000 avatar substars avatar swamp09 avatar tenderlove avatar unclebilly avatar vjt avatar yahonda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

oracle-enhanced's Issues

"undefined method `[]' for nil:NilClass" when running "rake middleware" task

  M Y    C O N F I G U R A T I O N

RUBY: ruby-1.8.7-p249 (on rvm)
RAILS: Rails 3.0.0.beta4
GEMS:
*** LOCAL GEMS ***
abstract (1.0.0)
actionmailer (3.0.0.beta4, 3.0.0.beta)
actionpack (3.0.0.beta4, 3.0.0.beta)
activemodel (3.0.0.beta4, 3.0.0.beta)
activerecord (3.0.0.beta4, 3.0.0.beta)
activerecord-oracle_enhanced-adapter (1.2.4)
activeresource (3.0.0.beta4, 3.0.0.beta)
activesupport (3.0.0.beta4, 3.0.0.beta)
arel (0.4.0, 0.2.1)
builder (2.1.2)
bundler (1.0.0.beta.1, 0.9.26)
cgi_multipart_eof_fix (2.5.0)
daemons (1.1.0, 1.0.10)
erubis (2.6.6, 2.6.5)
fastthread (1.0.7)
gem_plugin (0.2.3)
i18n (0.4.1, 0.3.7)
jrails (0.6.0)
mail (2.2.5, 2.2.3, 2.1.5.3)
memcache-client (1.8.3, 1.7.8)
mime-types (1.16)
mongrel (1.2.0.pre2, 1.1.5)
pdfkit (0.3.3)
polyglot (0.3.1)
rack (1.1.0)
rack-mount (0.6.4, 0.6.3, 0.4.7)
rack-test (0.5.4)
rails (3.0.0.beta4, 3.0.0.beta)
railties (3.0.0.beta4, 3.0.0.beta)
rake (0.8.7)
rdoc (2.5.8)
rspec (1.3.0)
ruby-graphviz (0.9.12)
ruby-oci8 (2.0.4)
ruby-plsql (0.4.3)
sqlite3-ruby (1.3.0)
text-format (1.0.0)
text-hyphen (1.0.0)
thor (0.13.7, 0.13.6)
treetop (1.4.8)
tzinfo (0.3.22)

GEMS included by the bundle:

abstract (1.0.0)
actionmailer (3.0.0.beta4)
actionpack (3.0.0.beta4)
activemodel (3.0.0.beta4)
activerecord (3.0.0.beta4)
activerecord-oracle_enhanced-adapter (1.3.0 6f204a4)
activeresource (3.0.0.beta4)
activesupport (3.0.0.beta4)
arel (0.4.0)
authlogic (2.1.3 a087ad0)
builder (2.1.2)
bundler (1.0.0.beta.1)
erubis (2.6.5)
i18n (0.4.1)
jrails (0.6.0)
mail (2.2.5)
mime-types (1.16)
pdfkit (0.3.3)
polyglot (0.3.1)
rack (1.1.0)
rack-mount (0.6.4)
rack-test (0.5.4)
rails (3.0.0.beta4 0421fb7)
railties (3.0.0.beta4)
rake (0.8.7)
rspec (1.3.0)
ruby-oci8 (2.0.4)
ruby-plsql (0.4.3)
thor (0.13.6)
treetop (1.4.8)
tzinfo (0.3.22)

When I try to run 'rake middleware' I got an error "undefined method `[]' for nil:NilClass".
Using the same command with the option '--trace', as suggested by the output, I see that it seems a problem of oracle_enhanced_tasks.rb, here is the full output of the command 'rake middleware --trace':

rake aborted!
undefined method `[]' for nil:NilClass
/home/asalicetti/.rvm/gems/ruby-1.8.7-p249/bundler/gems/oracle-enhanced-6f204a4/lib/active_record/connection_adapters/oracle_enhanced_tasks.rb:3
/home/asalicetti/.rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-0421fb7/activesupport/lib/active_support/dependencies.rb:212:in `require'
/home/asalicetti/.rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-0421fb7/activesupport/lib/active_support/dependencies.rb:212:in `require'
/home/asalicetti/.rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-0421fb7/activesupport/lib/active_support/dependencies.rb:198:in `load_dependency'
/home/asalicetti/.rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-0421fb7/activesupport/lib/active_support/dependencies.rb:554:in `new_constants_in'
/home/asalicetti/.rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-0421fb7/activesupport/lib/active_support/dependencies.rb:198:in `load_dependency'
/home/asalicetti/.rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-0421fb7/activesupport/lib/active_support/dependencies.rb:212:in `require'
/home/asalicetti/.rvm/gems/ruby-1.8.7-p249/bundler/gems/oracle-enhanced-6f204a4/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1777
/home/asalicetti/.rvm/gems/ruby-1.8.7-p249/gems/bundler-1.0.0.beta.1/lib/bundler/runtime.rb:48:in `require'
/home/asalicetti/.rvm/gems/ruby-1.8.7-p249/gems/bundler-1.0.0.beta.1/lib/bundler/runtime.rb:48:in `require'
/home/asalicetti/.rvm/gems/ruby-1.8.7-p249/gems/bundler-1.0.0.beta.1/lib/bundler/runtime.rb:47:in `each'
/home/asalicetti/.rvm/gems/ruby-1.8.7-p249/gems/bundler-1.0.0.beta.1/lib/bundler/runtime.rb:47:in `require'
/home/asalicetti/.rvm/gems/ruby-1.8.7-p249/gems/bundler-1.0.0.beta.1/lib/bundler/runtime.rb:38:in `each'
/home/asalicetti/.rvm/gems/ruby-1.8.7-p249/gems/bundler-1.0.0.beta.1/lib/bundler/runtime.rb:38:in `require'
/home/asalicetti/.rvm/gems/ruby-1.8.7-p249/gems/bundler-1.0.0.beta.1/lib/bundler.rb:112:in `require'
/home/asalicetti/Ruby/Rails/GS3/config/application.rb:7
/home/asalicetti/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/home/asalicetti/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
/home/asalicetti/Ruby/Rails/GS3/Rakefile:4
/home/asalicetti/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:2383:in `load'
/home/asalicetti/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:2383:in `raw_load_rakefile'
/home/asalicetti/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:2017:in `load_rakefile'
/home/asalicetti/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/home/asalicetti/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:2016:in `load_rakefile'
/home/asalicetti/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:2000:in `run'
/home/asalicetti/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/home/asalicetti/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/home/asalicetti/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/bin/rake:31
/home/asalicetti/.rvm/rubies/ruby-1.8.7-p249/bin/rake:24:in `load'
/home/asalicetti/.rvm/rubies/ruby-1.8.7-p249/bin/rake:24

I've done a little debug and it turns out that 'Rails.env', at runtime, is equal to 'development', but Rails.env['adapter'] is undefined.

Looking on Google I found this:
http://groups.google.com/group/oracle-enhanced/browse_thread/thread/7e246a9b85c4b2ed/a48a06f8946bd400

Basically the solution suggested here is to remove the bit of code:
, :require => 'active_record/connection_adapters/oracle_enhanced_adapter'
from the line of the activerecord-oracle_enhanced-adapter gem's requirement.

It works!

My question is: does it have any drawback such kind of fix?
I don't remember even why I put it on there...

Thank you!

issues using emulate_booleans and emulate_booleans_from_strings

I am having issues using the two emulate booleans options with an 11G database.

I found the boolean values seem to be set as NUMBER(1). So I have overridden simplified_type(field_type) to use this type. This was failing at times, and it seems the at times the field_type is actually coming in as NUMBER(1)(1) or even NUMBER(1)(1)(1). Other field types also have the size repeated several times.

Also, this seems to be different between my dev database and my production database.

I put in a temporary fix, but I would like to understand why this is happening.

My fix in simplified_type is:

   return :boolean if OracleEnhancedAdapter.emulate_booleans && ['NUMBER(1)', 'NUMBER(1)(1)', 'NUMBER(1)(1)(1)', 'NUMBER(1)(1)(1)(1)'].include?(field_type)

Any idea why this is happening?

find_each broken

Hi,

Ruby 1.8.7
Rails 3.0.5
activerecord-oracle_enhanced-adapter 1.3.2

When using the oracle_enhanced adapter the find_each method breaks:

/usr/local/lib/ruby/gems/1.8/gems/activerecord-3.0.5/lib/active_record/
relation/batches.rb:68:in `find_in_batches': undefined method `gteq'
for nil:NilClass (NoMethodError)
        from /usr/local/lib/ruby/gems/1.8/gems/activerecord-3.0.5/lib/
active_record/relation/batches.rb:20:in `find_each'
        from /usr/local/lib/ruby/gems/1.8/gems/activerecord-3.0.5/lib/
active_record/base.rb:440:in `__send__'
        from /usr/local/lib/ruby/gems/1.8/gems/activerecord-3.0.5/lib/
active_record/base.rb:440:in `find_each'
        from find_each.rb:19

Line 68 is: records = relation.where(primary_key.gteq(start)).all

My code was simply:

require 'active_record'

class SiteLocation < ActiveRecord::Base
  set_table_name = 'site_location'
  set_primary_key 'schoolid'
end

ActiveRecord::Base.establish_connection(
  :adapter  => 'oracle_enhanced',
  :database => 'our_db',
  :username => 'user',
  :password => 'xxxx'
)

SiteLocation.find_each{ |rec|
  p rec
}

Removing the "set_primary_key" call did not help.

can't start in production mode in mac osx

rails 2.3.5
oracle_enhanced: 1.3.1

/Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010. Use #requirement
oci8.c:270:in oci8lib.bundle: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor (OCIError)
from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-oracle_enhanced-adapter-1.3.1/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:244:in new' from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-oracle_enhanced-adapter-1.3.1/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:244:innew_connection'
from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-oracle_enhanced-adapter-1.3.1/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:349:in initialize' from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-oracle_enhanced-adapter-1.3.1/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:24:innew'
from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-oracle_enhanced-adapter-1.3.1/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:24:in initialize' from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-oracle_enhanced-adapter-1.3.1/lib/active_record/connection_adapters/oracle_enhanced_connection.rb:9:innew'
from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-oracle_enhanced-adapter-1.3.1/lib/active_record/connection_adapters/oracle_enhanced_connection.rb:9:in create' from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-oracle_enhanced-adapter-1.3.1/lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb:13:inoracle_enhanced_connection'
from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in send' from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:innew_connection'
from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:245:in checkout_new_connection' from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:188:incheckout'
from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in loop' from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:incheckout'
from /Users/qichunren/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/monitor.rb:242:in synchronize' from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:183:incheckout'
from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:98:in connection' from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:326:inretrieve_connection'
from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:123:in retrieve_connection' from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:115:inconnection'
from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-2.3.5/lib/active_record/base.rb:3113:in quoted_table_name' from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/acts_as_audited-1.1.1/lib/acts_as_audited.rb:82:inacts_as_audited'
from /Users/qichunren/code/demo_Business/app/models/admin.rb:24
from /Users/qichunren/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require' from /Users/qichunren/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:158:in require' from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:265:inrequire_or_load'
from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:224:in depend_on' from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:136:inrequire_dependency'
from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/rails-2.3.5/lib/initializer.rb:414:in load_application_classes' from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/rails-2.3.5/lib/initializer.rb:413:ineach'
from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/rails-2.3.5/lib/initializer.rb:413:in load_application_classes' from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/rails-2.3.5/lib/initializer.rb:411:ineach'
from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/rails-2.3.5/lib/initializer.rb:411:in load_application_classes' from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/rails-2.3.5/lib/initializer.rb:197:inprocess'
from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/rails-2.3.5/lib/initializer.rb:113:in send' from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/rails-2.3.5/lib/initializer.rb:113:inrun'
from /Users/qichunren/code/demo_Business/config/environment.rb:14
from /Users/qichunren/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require' from /Users/qichunren/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in require' from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:innew_constants_in'
from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in require' from /Users/qichunren/.rvm/gems/ruby-1.8.7-p302/gems/rails-2.3.5/lib/commands/server.rb:84 from /Users/qichunren/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:ingem_original_require'
from /Users/qichunren/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from script/server:3
usermatoMacBook-Pro:demo_Business qichunren$

and in RAILS_ROOT/sqlnet.log:


Fatal NI connect error 12514, connecting to:
(DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=zhaodb)(CID=(PROGRAM=ruby)(HOST=usermatoMacBook-Pro.local)(USER=qichunren)))(ADDRESS=(PROTOCOL=TCP)(HOST=114.80.138.164)(PORT=1521)))

VERSION INFORMATION:
TNS for MacOS X Server: Version 10.2.0.4.0 - Production
TCP/IP NT Protocol Adapter for MacOS X Server: Version 10.2.0.4.0 - Production
Time: 01-NOV-2010 11:10:40
Tracing not turned on.
Tns error struct:
ns main err code: 12564
TNS-12564: Message 12564 not found; No message file for product=network, facility=TNS
ns secondary err code: 0
nt main err code: 0
nt secondary err code: 0
nt OS err code: 0

Column case wrong/changed in v1.3.0

I have a table with a column named 'number' which works fine in v1.2.4.

After upgrading to 1.3.0, Rails referres to the column as 'TABLENAME'.'NUMBER' (all uppercase), which fails with an ORA-00904 invalid identifier.

Rake fails in oracle_enhanced_tasks.rb

Using rails 3 beta 3, and the rails3_oracle_patches from the rails3_oracle_sample, then rake -T doesn't work.

rake aborted!
undefined method `[]' for nil:NilClass
/Users/copa/.rvm/gems/ree-1.8.7-2010.01/bundler/gems/oracle-enhanced-35f26176bf0c8e76ceaff468030e8aebad7d65bf-rails3/lib/active_record/connection_adapters/oracle_enhanced_tasks.rb:4

Basically ActiveRecord::Base.configurations is empty, it hasn't loaded database.yml yet.

Rake test tasks cannot drop test database with 10g express

When running any rake db:test command that will first drop the test database (clone, purge, load...) on an Oracle 10g Express Edition database, the connector returns an ORA-00904: Invalid identifier exception on the following query:

select type_name from user_types

On 10g, the "type_name" column has been renamed to "name".

I'm using:
activerecord-oracle_enhanced-adapter 1.3.2
ruby-oci8 2.0.4
activerecord 3.0.3

valid table names treated as if invalid

I ran into an issue where valid_table_name? returns false for schema names with a $ in them, even though $ is valid in schema names. This ends up causing quote_table_name to quote these table names and the result can be an error like:

OCIError: ORA-00972: identifier is too long

For example "ops$username.an_otherwise_ok_name" is 33 characters and bombs even though the individual parts are below the 30 character limit.

I patched this issue with bahuvrihi/oracle-enhanced@625395760c831e3f460e073fffc09d2221dc3ace. The patch also adds support for other irregular but legal characters such as '@' in a database link. As an FYI I am no database expert and I was not able to run the full test suite, just the parts I modified. Please be sure to double-check my work. Thanks!

Error in oracle_enhanced_adapter.rb line 131

I got a error when i try to launch rails console.

ERROR:
D:\data\My Dropbox\HQ\projets\hqp>rails console
C:/Ruby187/lib/ruby/gems/1.8/gems/oracle_enhanced-1.2.5/lib/active_record/connec
tion_adapters/oracle_enhanced_adapter.rb:131:in alias_method': undefined method add_order!' for class `Class' (NameError)

If I comment out line 131 and 132 in oracle_enhanced_adapter.rb it's work.

D:\data\My Dropbox\HQ\projets\hqp>bundle list
Gems included by the bundle:

  • abstract (1.0.0)
  • actionmailer (3.0.3)
  • actionpack (3.0.3)
  • activemodel (3.0.3)
  • activerecord (3.0.3)
  • activerecord-oracle_enhanced-adapter (1.3.2)
  • activeresource (3.0.3)
  • activesupport (3.0.3)
  • arel (2.0.7)
  • builder (2.1.2)
  • bundler (1.0.9)
  • erubis (2.6.6)
  • i18n (0.5.0)
  • mail (2.2.14)
  • mime-types (1.16)
  • oracle_enhanced (1.2.5)
  • polyglot (0.3.1)
  • rack (1.2.1)
  • rack-mount (0.6.13)
  • rack-test (0.5.7)
  • rails (3.0.3)
  • railties (3.0.3)
  • rake (0.8.7)
  • ruby-oci8 (2.0.4)
  • sinatra (1.1.2)
  • thor (0.14.6)
  • tilt (1.2.2)
  • treetop (1.4.9)
  • tzinfo (0.3.24)

D:\data\My Dropbox\HQ\projets\hqp>ruby --version
ruby 1.8.7 (2010-12-23 patchlevel 330) [i386-mingw32]

D:\data\My Dropbox\HQ\projets\hqp>gem env
RubyGems Environment:

  • RUBYGEMS VERSION: 1.4.2
  • RUBY VERSION: 1.8.7 (2010-12-23 patchlevel 330) [i386-mingw32]
  • INSTALLATION DIRECTORY: C:/Ruby187/lib/ruby/gems/1.8
  • RUBY EXECUTABLE: C:/Ruby187/bin/ruby.exe
  • EXECUTABLE DIRECTORY: C:/Ruby187/bin
  • RUBYGEMS PLATFORMS:
    • ruby
    • x86-mingw32
  • GEM PATHS:
    • C:/Ruby187/lib/ruby/gems/1.8
    • D:/Documents and Settings/cx4316/.gem/ruby/1.8
  • GEM CONFIGURATION:
    • :update_sources => true
    • :verbose => true
    • :benchmark => false
    • :backtrace => false
    • :bulk_threshold => 1000
  • REMOTE SOURCES:

Running on windows xp.

Thanks!

OS Authentication Gets Mungled

OCI8 allows me to use OS authentication if I pass nil:

OCI8.new(nil, nil, [database]) # works!

It does not work with empty strings:

OCI8.new('', '', [database]) # fails :(

oracle_enhanced mungles this a little. It occurs in OracleEnhancedOCIFactory::new_connection. The line (around line 257?):

username, password, database = config[:username].to_s, config[:password].to_s, config[:database].to_s

Converting the config[:username] with "to_s" turns my nil into an empty string. I removed the "to_s" and oracle_enhanced connects using OS authentication (because it honors the nil). And it still works when I pass in a hard-coded username and password.

Thanks for the great work!

Inconsistencies in eager loading with select

ActiveRecord has an issue determining when to revert to the left-outer-join strategy for eager loading, and as a result the behavior of select + include can be inconsistent.

I saw your patches to rails 3 for that problem. They're a big improvement but they will not handle all valid identifiers much as in http://github.com/rsim/oracle-enhanced/issues/13. I opened a ticket for rails regarding this issue. I propose they move the tables_in_string method to the adapter so you can make it more robust on oracle. Thought you might like to know!

Sequence Case Sensitivity Issues

I am running into an issue with sequences and this gem.

The gem creates the sequence as "TABLENAME_SEQ" appropriately quoted, however when trying to retrieve it, it uses "TABLENAME_seq". This causes the sequence to not be found (at least this is the case in our Oracle installation). This appears to be due to the options being passed to "default_sequence_name" differing from migration time to run time. At migration time, the "table name" param is all lower case, however at run time the table name is all upper case (due to the result of "describe" giving the table name as stored...uppercase). Since "quote_table_name" will not upcase anything that already starts with an uppercase letter, the mixed case remains all the way through to the query.

I don't have a fix to recommend for this. I used a naive fix that works for our specific case by downcasing anything sent to default_sequence_name, however I am unsure of what other issues this may cause in a broader user base.

Getting weird issues with 20:Fixnum.empty? call

Hi,

I have the following database.yml config:

     development:
       adapter: oracle_enhanced
       database: xxx/yyy
       username: zzz
       password: aaa
       encoding: utf8
       cursor_sharing: similar

with the following model:

    class Status < ActiveRecord::Base
            set_table_name  "reporter_status"

    end

When trying to instantiate a Status object with:

    Status.first

I get the following:

    NoMethodError: undefined method `empty?' for 20:Fixnum
        from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1628:in `instantiate'
        from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:661:in `find_by_sql'
        from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:661:in `collect!'
        from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:661:in `find_by_sql'
        from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1548:in `find_every'
        from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1505:in `find_initial'
        from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:613:in `find'
        from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:623:in `first'
        from (irb):1

The schema for the table is as follows:

  create_table "reporter_status", :id => false, :force => true do |t|
    t.string   "identifier"
    t.integer  "serial",             :limit => 16, :precision => 16, :scale => 0
    t.string   "node",               :limit => 64
    t.string   "nodealias",          :limit => 64
    t.string   "manager",            :limit => 64
    t.string   "agent",              :limit => 64
    t.string   "alertgroup",         :limit => 64
    t.string   "alertkey",           :limit => 64
    t.string   "summary"
    t.string   "location",           :limit => 64
    t.integer  "class",              :limit => 16, :precision => 16, :scale => 0
    t.integer  "poll",               :limit => 16, :precision => 16, :scale => 0
    t.integer  "type",               :limit => 16, :precision => 16, :scale => 0
    t.integer  "tally",              :limit => 16, :precision => 16, :scale => 0
    t.boolean  "severity",                         :precision => 1,  :scale => 0
    t.integer  "owneruid",           :limit => 16, :precision => 16, :scale => 0
    t.integer  "ownergid",           :limit => 16, :precision => 16, :scale => 0
    t.integer  "acknowledged",       :limit => 16, :precision => 16, :scale => 0
    t.datetime "lastmodified"
    t.datetime "firstoccurrence"
    t.datetime "lastoccurrence"
    t.datetime "deletedat"
    t.boolean  "originalseverity",                 :precision => 1,  :scale => 0
    t.string   "ipaddress",          :limit => 64
    t.string   "customername",       :limit => 64
    t.integer  "devicecategory",     :limit => 8,  :precision => 8,  :scale => 0
    t.string   "position",           :limit => 64
    t.string   "tag",                :limit => 64
    t.string   "custlocation",       :limit => 64
    t.string   "ttno",               :limit => 64
    t.integer  "escalation",         :limit => 8,  :precision => 8,  :scale => 0
    t.datetime "clearedtime"
    t.datetime "acktime"
    t.string   "circuitdetails",     :limit => 50
    t.integer  "impactstate",        :limit => 4,  :precision => 4,  :scale => 0
    t.integer  "notificationid",     :limit => 16, :precision => 16, :scale => 0
    t.string   "accountid",          :limit => 64
    t.integer  "servicediff",        :limit => 4,  :precision => 4,  :scale => 0
    t.string   "relationship",       :limit => 64
    t.integer  "sourceserverserial", :limit => 16, :precision => 16, :scale => 0
    t.string   "servername",         :limit => 64,                                :null => false
    t.integer  "serverserial",       :limit => 16, :precision => 16, :scale => 0, :null => false
    t.decimal  "expiretime"
    t.string   "alerttype",          :limit => 64
  end

Any ideas?

Regards

"database" connection key interpretation change breaks connections to TNS-named databases

In our oracle client setup, we use TNS aliases set up in the default location, $ORACLE_HOME/network/admin/tnsnames.ora. In oracle_enhanced 1.2.3, we could use database: somedb to refer to the database aliased as "somedb" in tnsnames.ora. In 1.3.0, that no longer works โ€” we get ORA-12154, could not resolve the connect identifier errors.

The relevant change seems to be a6b5c0d. The root of the problem is apparently that oracle_enhanced now assumes that an unqualified database name is relative to a host and port and then assumes that the host:port is localhost:1521 if not specified.

By inspection of the code, we discovered that if you set the TNS_ADMIN environment variable, oracle_enhanced won't monkey with the specified database name. Since we're using the default TNS_ADMIN location, though, we'd rather not set the environment variable (it's redundant). I don't have particularly broad experience with oracle deployments, but my impression is that using tnsnames is more common than not. It seems like it would be nicer if oracle_enhanced would just leave the database value alone if you don't specify a host or port.

Is this a change you'd be willing to accept? I could provide a patch if so.

TypeError: can't convert nil into String

Any call to an oracle backed model throws this error.

Step 2 from the Troubleshooting guide works fine: http://github.com/rsim/oracle-enhanced/wiki/Troubleshooting

Step 3 doesn't work. It dies with:

require 'activerecord'
Gem::LoadError: can't activate activerecord (= 2.3.9, runtime) for [], already activated activerecord-3.0.1 for []
from /usr/local/lib/site_ruby/1.8/rubygems.rb:233:in activate' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:35:inrequire'
from (irb):4

Infoaccess::HrDirectoryAdmin
TypeError: can't convert nil into String
from /home/jpd800/.bundler/ruby/1.8/oracle-enhanced-1551b79913bc/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:245:in initialize' from /home/jpd800/.bundler/ruby/1.8/oracle-enhanced-1551b79913bc/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:245:innew'
from /home/jpd800/.bundler/ruby/1.8/oracle-enhanced-1551b79913bc/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:245:in new_connection' from /home/jpd800/.bundler/ruby/1.8/oracle-enhanced-1551b79913bc/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:350:ininitialize'
from /home/jpd800/.bundler/ruby/1.8/oracle-enhanced-1551b79913bc/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:24:in new' from /home/jpd800/.bundler/ruby/1.8/oracle-enhanced-1551b79913bc/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:24:ininitialize'
from /home/jpd800/.bundler/ruby/1.8/oracle-enhanced-1551b79913bc/lib/active_record/connection_adapters/oracle_enhanced_connection.rb:9:in new' from /home/jpd800/.bundler/ruby/1.8/oracle-enhanced-1551b79913bc/lib/active_record/connection_adapters/oracle_enhanced_connection.rb:9:increate'

ORA-19011 when reading large XMLType columns

When reading large XMLType columns, somehow oracle_enhanced-adapter reads it wrong and does not treat it like a CLOB. Oracle then raises: "ORA-19011: Character string buffer too small".

For now, I managed the situation this way:

# does not work, raises "ORA-19011: Character string buffer too small"
rec = MyTable.find_by_somekey(id)

# works
rec = MyTable.where(["somekey = ?", id]).select('(rawxml).getClobVal() as rawxml').first

Here's the backtrace:

.../vendor/bundle/ruby/1.8/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:207:in `log'
.../vendor/bundle/ruby/1.8/gems/activerecord-oracle_enhanced-adapter-1.3.2/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1077:in `log'
.../vendor/bundle/ruby/1.8/gems/activerecord-oracle_enhanced-adapter-1.3.2/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1034:in `select'
.../vendor/bundle/ruby/1.8/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all'
.../vendor/bundle/ruby/1.8/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract/query_cache.rb:56:in `select_all'
.../vendor/bundle/ruby/1.8/gems/activerecord-3.0.5/lib/active_record/base.rb:467:in `find_by_sql'
.../vendor/bundle/ruby/1.8/gems/activerecord-3.0.5/lib/active_record/relation.rb:64:in `to_a'
.../vendor/bundle/ruby/1.8/gems/activerecord-3.0.5/lib/active_record/relation/finder_methods.rb:333:in `find_first'
.../vendor/bundle/ruby/1.8/gems/activerecord-3.0.5/lib/active_record/relation/finder_methods.rb:122:in `first'
.../vendor/bundle/ruby/1.8/gems/activerecord-3.0.5/lib/active_record/relation/finder_methods.rb:234:in `send'
.../vendor/bundle/ruby/1.8/gems/activerecord-3.0.5/lib/active_record/relation/finder_methods.rb:234:in `find_by_attributes'
.../vendor/bundle/ruby/1.8/gems/activerecord-3.0.5/lib/active_record/base.rb:987:in `send'
.../vendor/bundle/ruby/1.8/gems/activerecord-3.0.5/lib/active_record/base.rb:987:in `method_missing'

DESC teble_name failed; does it exist?

Hi,
I found weird behavior inside oracle_enhanced_connection.rb (version 1.3.0) file, from where i always get error mentioned in title. I looked into source code of this file at line 68, which states "if result = select_one(sql)"
before this statement I created code "puts sql" which returns SELECT statement which is about to be executed, when I run this statement inside sql developer, under same connection(user,password) as set in database.yml, I get result one line, but inside oracle_enhanced_connection.rb will return nil and cause exception from line 76.

JRuby issues when active_record.default_timezone is not 'utc'

OracleEnhancedOCIConnection has the following code:

# code from Time.time_with_datetime_fallback
begin
Time.send(Base.default_timezone, year, month, day, hour, min, sec, usec)
rescue
offset = Base.default_timezone.to_sym == :local ? ::DateTime.local_offset : 0
::DateTime.civil(year, month, day, hour, min, sec, offset)
end

OracleEnhancedJDBCConnection should have similar behaviour when active_record.default_timezone is not 'utc'

BLOB fields terribly slow

Mapping oracle's blob columns to the ruby equivalent is terribly slow right now. Fetching 135 records over a slow connection and creating the appropriate model objects takes about 5 seconds. I've added some benchmark stuff to OracleEnhancedJDBCConnection#select_no_retry. My select_no_retry run produces the following numbers:

VARCHAR2 0.03s 0.62%
TIMESTAMP 0.08s 1.47%
NUMBER 0.13s 2.35%
BLOB 5.25s 95.56%

I have only a single BLOB column (the picture), but no pictures have been set yet (no data).

I'm using java 1.6, Jruby 1.4.0, rails 2.3.5, oracle-enhanced 1.2.3, Oracle 10g express edition, and the ojdbc14.jar jdbc driver.

Please let me know if you need more details. Thanks for your great work on the enhanced adapter!

Associations BLOBs issue

Hi,

I'm an absolute newbie to rails but I encountered a problem using the following structure:

create_table :experiments do |t|
  t.string :name
end
create_table :experiment_attachments do |t|
  t.references :experiment
  t.references :attachment
end
create_table :attachments do |t|
  t.binary :content
  t.string :description
end

class Attachment < ActiveRecord::Base
  has_many :experiment_attachments
  has_many :experiments, :through => :experiment_attachments
end
class Experiment < ActiveRecord::Base
  has_many :experiment_attachments
  has_many :attachments, :through => :experiment_attachments, :uniq => true
end
class ExperimentAttachment < ActiveRecord::Base
  belongs_to :experiment
  belongs_to :attachment
end

In the app I set up an experiment and a related attachment instance:

e=Experiment.create(:name => "test")
a=e.attachments.create(:description => "mmm", :content => "ddfgdg")

The following query leads to an ORA-00932 error:

e.attachments

If I remove the BLOB column (:content) in the attachment model it works as expected. This error does not occur with the mysql2 adapter. Btw, my configuration: Rails 3.0.3, Ruby 1.9.2p136, oracle-enhanced 1.3.2, ruby-oci8 2.0.4

What do I do wrong here?

Udo

Table/Column alias maximum length in schema_statements

I just came across an obscure little bug in AR - I ran something like this:

SomeModel.count(:group => 'foofoofoofoo, barbarbarbar, bazbazbazbaz')

which generates a (unnecessary) column alias longer than the 30 characters allowed by Oracle:

SELECT 1 AS foofoofoofoo_barbarbarbar_bazbazbazbaz FROM dual;
ORA-00972: identifier is too long

This seems to have been addressed to some extent between AR2.1.2 (where I'm stuck at present) and 2.3.4, which has

module ActiveRecord
module ConnectionAdapters # :nodoc:
module SchemaStatements
# Returns a Hash of mappings from the abstract data types to the native
# database types. See TableDefinition#column for details on the recognized
# abstract data types.
def native_database_types
{}
end

  # This is the maximum length a table alias can be
  def table_alias_length
    255
  end

  # Truncates a table alias according to the limits of the current adapter.
  def table_alias_for(table_name)
    table_name[0..table_alias_length-1].gsub(/\./, '_')
  end

For Oracle, we need table_alias_length to return 30.

Not that I can actually use it, of course (I had to hack calculations.rb, grrr) but it would be nice to see it in the adapter if I ever get to update...

Rails.logger nil on ruby 1.9.2-head (actually 1.9.3)

Rails 3 beta 4
Ruby 1.9.2-head

On oracle_enhanced_core_ext.rb, line 57 I had to add a check to avoid a NullPointerException:
From:
if defined?(Rails.logger)
Rails.logger.warn warning_message
To:
if defined?(Rails.logger)
Rails.logger.warn warning_message if Rails.logger

idea about 'set_date(time)_columns'

instead of actually having to write column-name-symbols, it would be cool if we could determine patterns for symbol names....
here in germany we often use date-field-names with certain postfixes that make the field recognizable as date like '_seit' (since), '_bis' (until), 'am' (at)
so it would be lovely if we could just define, maybe an array to hold patterns for column recognition ... like [ /\w*
(am|seit|bis|at|on)/, /exceptionaldatename/ ]
just food for thought

Suppress logging optionally for class reloading

Hi Raimonds!

Thank you so much for oracle_enhanced. It's a blessing for those of us using Oracle with Rails.

Is there a way to suppress the logging of ActiveRecord's columns and keys lookup in development? Because classes keep being reloaded, my logs are overwhelmed with primary key, primary key trigger, and columns lookups moreso than actual queries.

Thank you!

Best,
Milan

schema dumper cant't generate right foreign key name

after rake db:migrate,it generate db/schema.rb,why :name is like this:

add_foreign_key "countries", "regions", :name => "sys_c005603"

add_foreign_key "provinces", "countries", :name => "sys_c005607"

Should I have to asign :name option in migration file? I think the adapter should make it auto.

active? doesn't check if connection is stale / database unresponsive

According to abstract_adapter.rb (from ActiveRecord) active? should check if the database is actually capable of responding (usually by issuing a "select 1", like in the ping method).

We have a production problem over this issue because the Cisco router drops inactive connections, ActiveRecord::Base.verify_active_connections! should resolve this issue, but this only works if active? checks for database response capabilty, like with postgres and mysql adapters.

PS I'm using OCI driver, accidentally closed the former issue :oops:
PS

Caching column information breaks migrations

Enable the column caching breaks migrations run in dev mode (production migrations are probably broken as well).

I've started to see 01451 errors after enabling column caching:

ORA-01451: column to be modified to NULL cannot be modified to NULL: ALTER TABLE versions MODIFY effective_date DATE DEFAULT NULL NULL

It appears like oracle expects the 'not null' or 'null' keyword not in a alter table statement when the column is already in this modus. Oracle enhanced adapter is smart enough to check what has to be changed (and what should not be mentioned by the migration) and only sends the necessarry commands). But when this information is cached it can happen that the enhanced adapter is out of sync and creates invalid alter table statements. nasty!

ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.cache_columns = true

ActiveRecord 2.3.5 does not write data to the database

Using version 1.3.1 of the adapter and version 2.3.5 of ActiveRecord, I can query data from the database. However, if I update a ActiveRecord model object and try to save it (using save and save!), it returns true and the model object in memory contains the updated data, but the database itself is unchanged. If I try to fetch the same record from the database, the changes aren't there in the returned ActiveRecord model object.

The account I'm using to connect to the database has privileges to update the database data. I can update the same data using the same connection information in other database admin programs. Any idea why this is happening?

Allowing JNDI connections through oracle enhanced

I've patched the new_connection method in the 'oracle_enhanced_adapter'.rb-file so that JNDI connections through Java are possible. I've taken inspiration from the activerecord-jdbc-adapter-0.9.2 gem code to make it work. Actually it's just a matter of calling Java classes through JRuby as you would do in native Java, so it's pretty straight forward and the modification is minimal. Hope this will be added in the next release (I couldn't found out how to contribute directly so I wanted to share):

module ActiveRecord
    module ConnectionAdapters
    include_class "jdbc_adapter.JdbcConnectionFactory"

    class OracleEnhancedJDBCConnection < OracleEnhancedConnection

    ...

    # added logic to support JNDI connections
    def new_connection(config)
      if config[:jndi]
        jndi = "java:comp/env/#{config[:jndi].to_s}"
        ctx = javax.naming.InitialContext.new
        ds = ctx.lookup(jndi)
        @raw_connection = JdbcConnectionFactory.impl do
          ds.connection
        end
        config[:driver] ||= @raw_connection.meta_data.connection.java_class.name
      else        
        username, password, database = config[:username].to_s, config[:password].to_s, config[:database].to_s
        privilege = config[:privilege] && config[:privilege].to_s
        host, port = config[:host], config[:port]

        # connection using TNS alias
        if database && !host && !config[:url] && ENV['TNS_ADMIN']
          url = "jdbc:oracle:thin:@#{database || 'XE'}"
        else
          url = config[:url] || "jdbc:oracle:thin:@#{host || 'localhost'}:#{port || 1521}:#{database || 'XE'}"
        end

        prefetch_rows = config[:prefetch_rows] || 100
        cursor_sharing = config[:cursor_sharing] || 'force'
        # by default VARCHAR2 column size will be interpreted as max number of characters (and not bytes)
        nls_length_semantics = config[:nls_length_semantics] || 'CHAR'
        # get session time_zone from configuration or from TZ environment variable
        time_zone = config[:time_zone] || ENV['TZ'] || java.util.TimeZone.default.getID

        properties = java.util.Properties.new
        properties.put("user", username)
        properties.put("password", password)
        properties.put("defaultRowPrefetch", "#{prefetch_rows}") if prefetch_rows
        properties.put("internal_logon", privilege) if privilege

        @raw_connection = java.sql.DriverManager.getConnection(url, properties)
      end
    end
  end
end

The adapter complains about no ojdbc14.jar at the time of being included but not used

I'm working on an JRuby on Rails app which allows multiple database types. I include multiple JDBC connection adapter gems (including oracle-enhanced) and let the user/admin choose the connection type in database.yml.
However, oracle-enhanced looks for ojdbc14.jar file at the time the class is being loaded (a static block in lib/active_record/connection_adapters/oracle_enhanced_jdbc_connection.rb) and raises an exception (line 26) when not found, even if oracle-enhanced is not referenced in database.yml and thus not to be used at all.
The easy fix is to comment out the 'raise' line but I believe it can be done in a prettier way.

structure_drop creating, but not executing, sql to drop schema

I was having issues where rake db:drop wouldn't actually drop either table or sequence, so I dug into the code to find where oracle-enhanced was dropping these items.

I found structure_drop, which seems to fit my needs exactly. However, when I run:
ActiveRecord::Base.connection.structure_drop

I'm getting back the SQL to drop all the tables, returned as a long string, but it's not actually executed. When I run that SQL through sqlplus, it does seem to be valid, and the tables/sequences are dropped.

I feel like I must be missing something very simple, but I'm executing that ruby statement under the same user/pass as the sqlplus, and getting different results.

I've tried this with both 1.8.7p299 and 1.9.1p378 using ActiveRecord 3.0.0beta4 and activerecord-oracle_enhanced-adapter version 1.3.0

Thoughts?

active? doesn't check if connection is stale / database unresponsive

According to abstract_adapter.rb (from ActiveRecord) active? should check if the database is actually capable of responding (usually by issuing a "select 1", like in the ping method).

We have a production problem over this issue because the Cisco router drops inactive connections, ActiveRecord::Base.verify_active_connections! should resolve this issue, but this only works if active? checks for database response capabilty, like with postgres and mysql adapters.

schema dump produces a lot of precision

When I run rake db:schema:dump, all my integers and booleans are given redundant precision:

t.integer  "patient_id",         :precision => 38, :scale => 0
t.integer  "user_id",            :precision => 38, :scale => 0
t.integer  "parent_id",          :precision => 38, :scale => 0
t.boolean  "is_deleted",     :precision => 1,  :scale => 0
t.boolean  "display_status", :precision => 1,  :scale => 0

Is there a way for oracle-enhanced to suppress:precision => 38, :scale => 0 for integers and :precision => 1, :scale => 0 for booleans?

Do people just live with all this precision? Or is there something about my installation that is misconfigured? Thanks!

RAW Type Would be Nice

We love the adapter but would like to use RAW to store some encoded binary information.

I have a patch I would like to submit that seems to dump/restore the raw type correctly.

I can't run the tests when schema_format = :sql

When I configured active_record.schema_format = :sql and I performed my tests the adapter didn't complete the dumping because it didn't can execute "--@@@--" (a constant that is used to separate the statements in development_structure.sql).

For while I fixed it replacing this constant to "\n\n" in a config/initializer file:
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter::STATEMENT_TOKEN = "\n\n"

Somebody already did have this problem?

Connection errors. oci8.c:270:in oci8lib_191.so: ORA-12154: TNS:could not resolve the connect identifier

Note: We do not use tnsnames.ora. We use Oracle OID. Always worked with standard activerecord oracle adapter.

Worked perfectly before 1.9.2
ruby 1.9.2p0 (2010-08-18) [i386-mingw32]
gems 1.3.7
Oracle client: SQL*Plus: Release 11.2.0.1.0

Connection errors with these gems installed:

activemodel (3.0.1)
activerecord (3.0.1)
activerecord-oracle_enhanced-adapter (1.3.1)
activesupport (3.0.1)
arel (1.0.1)
builder (2.1.2)
i18n (0.4.1)
minitest (1.6.0)
rake (0.8.7)
rdoc (2.5.8)
ruby-oci8 (2.0.4 x86-mingw32)
tzinfo (0.3.23)

ActiveRecord::Base.establish_connection(
:adapter => 'oracle_enhanced',
:database => 'mydb',
:username => 'username',
:password => 'mypassword'
)

Error:

oci8.c:270:in oci8lib_191.so: ORA-12154: TNS:could not resolve the connect identifier specified (OCIError)
from D:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-oracle_enhanced-adapter-1.3.1/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:244:in new' from D:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-oracle_enhanced-adapter-1.3.1/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:244:innew_connection'
from D:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-oracle_enhanced-adapter-1.3.1/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:349:in initialize' from D:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-oracle_enhanced-adapter-1.3.1/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:24:innew'
from D:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-oracle_enhanced-adapter-1.3.1/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:24:in initialize' from D:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-oracle_enhanced-adapter-1.3.1/lib/active_record/connection_adapters/oracle_enhanced_connection.rb:9:innew'
from D:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-oracle_enhanced-adapter-1.3.1/lib/active_record/connection_adapters/oracle_enhanced_connection.rb:9:in create' from D:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-oracle_enhanced-adapter-1.3.1/lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb:13:inoracle_enhanced_connection'
from D:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:230:in new_connection' from D:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:238:incheckout_new_connection'
from D:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:194:in block (2 levels) in checkout' from D:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:190:inloop'
from D:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:190:in block in checkout' from D:/ruby/lib/ruby/1.9.1/monitor.rb:201:inmon_synchronize'
from D:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:189:in checkout' from D:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:96:inconnection'
from D:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:318:in retrieve_connection' from D:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:97:inretrieve_connection'
from D:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in connection' from D:/ruby/lib/ruby/gems/1.9.1/gems/arel-1.0.1/lib/arel/engines/sql/engine.rb:9:inconnection'
from D:/ruby/lib/ruby/gems/1.9.1/gems/arel-1.0.1/lib/arel/engines/sql/relations/table.rb:37:in initialize' from D:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/base.rb:850:innew'
from D:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/base.rb:850:in arel_table' from D:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/base.rb:896:inrelation'
from D:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/named_scope.rb:32:in `scoped'

float maps to decimal maps to integer through schema dump & schema load iteration

When creating a schema dump the float type will degrade into a decimal, and decimal type will degrade into an integer.

Steps to reproduce:

  1. define a float column X, migrate it to database
  2. create a schema dump, the schema.rb will state "decimal" for type of column X
  3. load the acquired schema.rb file into the database, and dump again
  4. the new schema.rb will have type integer (number 38,0) for column X

Confirmed on Oracle 11 enterprise, Oracle 10 express, oracle-enhanced v1.3.2 and v.1.3.1 and activerecord 3.0.4 and 3.0.3

Reserved column names oracle rails 2.3.5

Hi, I have a problem with number column name in a legacy database which is oracle. The problem is that activerecord tries to execute SQL statement that gives an error :
ORA-00936: missing expression: select * from (SELECT * FROM "BINS" WHERE ("BINS".issuer_id = 5 AND (number like '%936214')) ) where rownum <= 1
Problem is with number like part of the statement, for oracle it should be quoted and in upper case, so how that could be done? Thanks in advance!
Best Regards,
Josip Povreslo

rake:db:test:clone_structure does not create valid SQL for Oracle 10g R 2

Hi. I'm trying to copy a dev database to test in order to test properly.

Given the following environment:
Rails 2.3.8
ruby-oci8 2.0.4
oracle_enhanced 1.2.4
Ruby 1.8.6 p 399 in RVM
Oracle 10g test database running locally on OS X
Oracle 11g development database running remotely

When I try to copy the development database to a test database in order to run specs on it,
Then I'm getting the following errors in this gist (the second file): https://gist.github.com/1fca1f0b2fb1f0d0f3eb

The gist shows part of the development_structure.sql file that is created by db:structure:dump starting on line 16 of lib/active_record/connection_adapters/oracle_enhanced.rake. My Oracle 10g instance does not like the STATEMENT_TOKEN that the structure_dump method uses starting at line 1203 of ib/active_record/connection_adapters/oracle_enhanced_adapter.rb. I replaced the STATEMENT_TOKEN "\n\n-- @@@ --\n\n" with ";\n\n" on line 1456 to get that to work.

Once that worked, I ran into the issue created by the SQL in the part of the gist called "unique constraint problem". Running this through the driver as well as through sqlplus resulted in an ORA-00955 error, as shown in the gist.

Based on these issues, I have some questions:

  1. Has the "rake db:test:clone_structure" task worked for people? I tried running the activerecord_oracle_enhanced tests (the last file in the gist) but didn't see any output.
  2. If so, what environment did it work in?
  3. I noticed that there isn't a spec for the rake task. I've used code from this post http://blog.codahale.com/2007/12/20/rake-vs-rspec-fight/ to add specs for rake tasks. Are there any objections to me making a fork, adding those spec changes and submitting?

Thanks,
Mark Nyon

ActiveRecord::Base #last throws error

I have a simple model, and when calling last on the class I get:

ActiveRecord::StatementInvalid: OCIError: ORA-00904: "APP"."VENDOR"."ID": invalid identifier: select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT * FROM APP.VENDOR ORDER BY APP.VENDOR.id DESC) raw_sql_ where rownum <= 1) where raw_rnum_ > 0

The #first method works fine.

quoted camelcase table names

I have a self-referencing many to many relation which causes rails to create an sql query with an alter table name when ordering by a column of the self referencing relation. The alter table name contains the name of the relation (pluralized) and the original table name. For example: users_FRIENDSHIPS.

This mixed case method doesn't pass the valid_table_name? method in OracleEnhancedAdapter, because it is treated as "CamelCase" and is therefore quoted in quote_table_name, causing the sql statement to be invalid.

This fixes my problem, but treats CamelCase names as valid:


def self.valid_table_name?(name)
   name = name.to_s
   name =~ /\A([A-Za-z_0-9]+\.)?[A-Za-z][A-Za-z_0-9\$#]*(@[A-Za-z_0-9\.]+)?\Z/ ? true : false
end

Patch to tables_in_string method breaks queries with MySQL

In our application we use oracle and mysql databases side-by-side. After introducing this gem, we started getting mysql queries failing due to missing join tables. After investigation, we found that "tables_in_string" the method patch was causing this issue.

Ideally, we should just apply this patch if the query is made against "OracleEnhanced" adapter. The rest of the adapters should rely on the default activerecord implementation.

We fixed it by adding the following code after the line 'establish_connection' in the ActiveRecord::Base class for the oracle adapter in our application:

if ActiveRecord::VERSION::MAJOR == 2 && ActiveRecord::VERSION::MINOR == 3
  require "active_record/associations"

  ActiveRecord::Associations::ClassMethods.module_eval do

    private
    def tables_in_string(string)
      return [] if string.blank?

      if self.connection.adapter_name == "OracleEnhanced"
        # always convert table names to downcase as in Oracle quoted table names are in uppercase
        # ignore raw_sql_ that is used by Oracle adapter as alias for limit/offset subqueries
        string.scan(/([a-zA-Z_][\.\w]+).?\./).flatten.map(&:downcase).uniq - ['raw_sql_']
      else
        string.scan(/([\.a-zA-Z_]+).?\./).flatten
      end

    end
  end
end

The oracle enhanced adapter should at least include something similar so that it doesn't disable other database adapters by changing their functionality.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.