jdbc_adapter tries to find indexes for model objects backed by views in Oracle 
and that raises the "ORA-01702: a view is not appropriate here" exception.
---------------------------------------------------------------------------------------------------------------------------------------------------------

                 Key: JRUBY-2634
                 URL: http://jira.codehaus.org/browse/JRUBY-2634
             Project: JRuby
          Issue Type: Bug
          Components: ActiveRecord-JDBC
    Affects Versions: JRuby 1.1.2, JRuby 1.0.2
         Environment: Application runs locally on OS: MS WinXP SP2 (Intel P4); 
Database: Oracle 10g - v10.2.0.3 (remote - OS: HP-UX); App Server: Tomcat 5.0 
(local); JDK: 1.6.0_06; activerecord-jdbc-adapter version: 0.8.1; Rails 
version: 1.2.6
            Reporter: Renato Passos Santos


( I'm trying all this in 'development' environment with Tomcat 5.0;  this 
application has been in production and running smoothly in a Linux + MRI + 
Apache + mod_rails setup for quite some time ).

The adm controller of the application tries to execute the following command in 
its login action:

@orgao = Orgao.find(:first, :conditions => parametros.unshift(condicoes.join(" 
and ")))

It's translated by the framework to the following query:

select * from (
                         select raw_sql_.*, rownum raw_rnum_ from (
                                                                                
                           SELECT * 
                                                                                
                           FROM orgaos 
                                                                                
                           WHERE (grau = 2 and uf = 'DF') 
                                                                                
                           ) raw_sql_ 
                         where rownum <= 1
                         ) 
where raw_rnum_ > 0

The query itself is alright; the problem is that the Orgao model object is 
backed by a view (named orgaos) in an Oracle database and the framework is 
trying to use _indexes_ for that view before returning any results - and that 
generates an "ORA-01702: a view is not appropriate here" exception. That's 
because views can have no indexes in Oracle.

Here is the full stack trace:

D:/JDev/tomcat/webapps/sicel/WEB-INF/gems/gems/activerecord-jdbc-adapter-0.8.1/lib/active_record/connection_adapters/jdbc_adapter.rb:332:in
 `indexes'
D:/JDev/tomcat/webapps/sicel/WEB-INF/gems/gems/activerecord-jdbc-adapter-0.8.1/lib/jdbc_adapter/jdbc_oracle.rb:147:in
 `indexes'
D:/JDev/tomcat/webapps/sicel/WEB-INF/vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/base.rb:42:in
 `indexes'
D:/JDev/tomcat/webapps/sicel/WEB-INF/vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/base.rb:27:in
 `columns_with_redhillonrails_core'
D:/JDev/tomcat/webapps/sicel/WEB-INF/gems/gems/activerecord-1.15.6/lib/active_record/base.rb:771:in
 `columns_hash'
D:/JDev/tomcat/webapps/sicel/WEB-INF/gems/gems/activerecord-1.15.6/lib/active_record/base.rb:1894:in
 `define_read_methods'
D:/JDev/tomcat/webapps/sicel/WEB-INF/gems/gems/activerecord-1.15.6/lib/active_record/base.rb:1851:in
 `method_missing'
D:/JDev/tomcat/webapps/sicel/WEB-INF/app/controllers/adm_controller.rb:69:in 
`login'
D:/JDev/tomcat/webapps/sicel/WEB-INF/gems/gems/actionpack-1.13.6/lib/action_controller/base.rb:1101:in
 `perform_action'
D:/JDev/tomcat/webapps/sicel/WEB-INF/gems/gems/actionpack-1.13.6/lib/action_controller/filters.rb:696:in
 `call_filters'
D:/JDev/tomcat/webapps/sicel/WEB-INF/gems/gems/actionpack-1.13.6/lib/action_controller/filters.rb:688:in
 `perform_action_with_filters'
D:/JDev/tomcat/webapps/sicel/WEB-INF/gems/gems/actionpack-1.13.6/lib/action_controller/benchmarking.rb:66:in
 `perform_action_with_benchmark'
file:/D:/JDev/tomcat/webapps/sicel/WEB-INF/lib/jruby-complete-1.1.2.jar!/benchmark.rb:293:in
 `measure'
D:/JDev/tomcat/webapps/sicel/WEB-INF/gems/gems/actionpack-1.13.6/lib/action_controller/benchmarking.rb:66:in
 `perform_action_with_benchmark'
D:/JDev/tomcat/webapps/sicel/WEB-INF/gems/gems/actionpack-1.13.6/lib/action_controller/rescue.rb:83:in
 `perform_action_with_rescue'
D:/JDev/tomcat/webapps/sicel/WEB-INF/gems/gems/actionpack-1.13.6/lib/action_controller/base.rb:435:in
 `process'
D:/JDev/tomcat/webapps/sicel/WEB-INF/gems/gems/actionpack-1.13.6/lib/action_controller/filters.rb:684:in
 `process_with_filters'
D:/JDev/tomcat/webapps/sicel/WEB-INF/gems/gems/actionpack-1.13.6/lib/action_controller/session_management.rb:114:in
 `process_with_session_management_support'
D:/JDev/tomcat/webapps/sicel/WEB-INF/gems/gems/actionpack-1.13.6/lib/action_controller/base.rb:334:in
 `process'
D:/JDev/tomcat/webapps/sicel/WEB-INF/gems/gems/rails-1.2.6/lib/dispatcher.rb:41:in
 `dispatch'
file:/D:/JDev/tomcat/webapps/sicel/WEB-INF/lib/jruby-rack-0.9.jar!/rack/adapter/rails.rb:37:in
 `serve_rails'
file:/D:/JDev/tomcat/webapps/sicel/WEB-INF/lib/jruby-rack-0.9.jar!/rack/adapter/rails.rb:44:in
 `call'
file:/D:/JDev/tomcat/webapps/sicel/WEB-INF/lib/jruby-rack-0.9.jar!/jruby/rack/rails.rb:129:in
 `call'
file:/D:/JDev/tomcat/webapps/sicel/WEB-INF/lib/jruby-rack-0.9.jar!/rack/handler/servlet.rb:22:in
 `call'
:1

I'd also attach the development log of the application but, for some unknown 
reason, nothing is appended to it when I use Warbler 0.9.9 to deploy it to 
Tomcat 5.0 (the log worked correctly when I was using JRuby 1.0.2 and Goldspike 
1.3 to package and deploy the application as a standalone - does that warrant 
another bug issue? And yes, the ORA-01702 exception did occur in that setup. 
Tomorrow I can try and assemble that environment again just to send some 
application log.)

It's also worth of note that the app uses the following plugins:

acts_as_paranoid
annotate_models
calendar_date_select
custom_scaffold
fckeditor
foreign_key_migrations
redhillonrails_core

And last, but not least: this bug is somewhat reminiscent of JRUBY-1966 but, if 
I understood correctly, the adapter checked if the "table" backing the model 
object indeed physically existed before proceeding to get metadata - and that 
would always fail for views in that issue. Here, the adapter tries to use the 
indexes of the "table" before checking if it's a physical table or a view, thus 
raising the exception.

Thanks for the attention,
Renato.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to