PiRSquared17 / activescaffold

Automatically exported from code.google.com/p/activescaffold
MIT License
0 stars 0 forks source link

Not Compatible With Parameterized Configuration #764

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Configure to use IBM DB2 on Rails adapter for DB2.
2. Set parameterized: true in database.yml
3. Execute an active scaffold configured controller.

What is the expected output? What do you see instead?
Expected to see typical AS list view of data.  Instead receiving the following 
error:
ActiveRecord::StatementInvalid (Statement execution failed: [IBM][CLI 
Driver][DB2/AIX64] SQL0206N  "<table name removed>.PARAMARRAY" is not valid in 
the context where it is used.  SQLSTATE=42703 SQLCODE=-206):

What version (or revision) of the product are you using?
Ruby 1.8.7 p248
Rails 2.3.4
Active Scaffold rails-2.2
DB2 on Rails 2.5.5

If this bug causes an exception, please paste at least the first 20 lines below.
ActiveRecord::StatementInvalid (Statement execution failed: [IBM][CLI 
Driver][DB2/AIX64] SQL0206N  "<table name removed>.PARAMARRAY" is not valid in 
the context where it is used.  SQLSTATE=42703 SQLCODE=-206):
  /opt/ror/ruby-ee-1.8.7-2010.01/lib/ruby/gems/1.8/gems/ibm_db-2.5.5/lib/active_record/connection_adapters/ibm_db_adapter.rb:985:in `execute_prepared_stmt'
  /opt/ror/ruby-ee-1.8.7-2010.01/lib/ruby/gems/1.8/gems/ibm_db-2.5.5/lib/active_record/connection_adapters/ibm_db_adapter.rb:720:in `prepared_select_without_query_cache'
  /opt/ror/ruby-ee-1.8.7-2010.01/lib/ruby/gems/1.8/gems/ibm_db-2.5.5/lib/active_record/connection_adapters/ibm_db_pstmt.rb:1858:in `prepared_select'
  /opt/ror/ruby-ee-1.8.7-2010.01/lib/ruby/gems/1.8/gems/ibm_db-2.5.5/lib/active_record/connection_adapters/ibm_db_pstmt.rb:1858:in `prepared_select'
  /opt/ror/ruby-ee-1.8.7-2010.01/lib/ruby/gems/1.8/gems/ibm_db-2.5.5/lib/active_record/connection_adapters/ibm_db_pstmt.rb:877:in `execute_simple_calculation'
  app/views/dashboard/index.rhtml:69:in `_run_rhtml_app47views47dashboard47index46rhtml'
  /opt/ror/passenger/lib/phusion_passenger/rack/request_handler.rb:92:in `process_request'

Original issue reported on code.google.com by Scott.R....@gmail.com on 16 Sep 2010 at 1:49

GoogleCodeExporter commented 9 years ago
ActiveScaffold rails-2.2 is uncompatible with rails-2.3.x. Please, specify real 
ActiveScaffold version or update to rails-2.3 or master branches.

Also, remove backtrace silencers or backtrace won't be useful becuase it won't 
include ActiveScaffold lines

Original comment by sergio.c...@gmail.com on 17 Sep 2010 at 7:44

GoogleCodeExporter commented 9 years ago

Original comment by sergio.c...@gmail.com on 17 Sep 2010 at 7:44

GoogleCodeExporter commented 9 years ago
ActiveScaffold version is 1.2RC1

Backtrace without silencers:

ActiveRecord::StatementInvalid (Statement execution failed: [IBM][CLI 
Driver][DB2/AIX64] SQL0206N  "<table name removed>.PARAMARRAY" is not valid in 
the context where it is used.  SQLSTATE=42703 SQLCODE=-206):
  /opt/ror/ruby-ee-1.8.7-2010.01/lib/ruby/gems/1.8/gems/ibm_db-2.5.5/lib/active_record/connection_adapters/ibm_db_adapter.rb:985:in `execute_prepared_stmt'
  /opt/ror/ruby-ee-1.8.7-2010.01/lib/ruby/gems/1.8/gems/ibm_db-2.5.5/lib/active_record/connection_adapters/ibm_db_adapter.rb:720:in `prepared_select_without_query_cache'
  /opt/ror/ruby-ee-1.8.7-2010.01/lib/ruby/gems/1.8/gems/ibm_db-2.5.5/lib/active_record/connection_adapters/ibm_db_pstmt.rb:1858:in `prepared_select'
  activerecord (2.3.4) lib/active_record/connection_adapters/abstract/query_cache.rb:81:in `cache_sql'
  /opt/ror/ruby-ee-1.8.7-2010.01/lib/ruby/gems/1.8/gems/ibm_db-2.5.5/lib/active_record/connection_adapters/ibm_db_pstmt.rb:1858:in `prepared_select'
  /opt/ror/ruby-ee-1.8.7-2010.01/lib/ruby/gems/1.8/gems/ibm_db-2.5.5/lib/active_record/connection_adapters/ibm_db_pstmt.rb:877:in `execute_simple_calculation'
  activerecord (2.3.4) lib/active_record/calculations.rb:134:in `calculate'
  activerecord (2.3.4) lib/active_record/calculations.rb:130:in `catch'
  activerecord (2.3.4) lib/active_record/calculations.rb:130:in `calculate'
  activerecord (2.3.4) lib/active_record/calculations.rb:48:in `count'
  vendor/plugins/active_scaffold/lib/active_scaffold/finder.rb:204:in `find_page'
  vendor/plugins/active_scaffold/lib/active_scaffold/actions/list.rb:72:in `do_list'
  vendor/plugins/active_scaffold/lib/active_scaffold/actions/list.rb:12:in `table'
  actionpack (2.3.4) lib/action_controller/base.rb:1331:in `send'
  actionpack (2.3.4) lib/action_controller/base.rb:1331:in `perform_action_without_filters'
  actionpack (2.3.4) lib/action_controller/filters.rb:617:in `call_filters'
  actionpack (2.3.4) lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
  actionpack (2.3.4) lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
  activesupport (2.3.4) lib/active_support/core_ext/benchmark.rb:17:in `ms'
  /opt/ror/ruby-ee-1.8.7-2010.01/lib/ruby/1.8/benchmark.rb:308:in `realtime'
  activesupport (2.3.4) lib/active_support/core_ext/benchmark.rb:17:in `ms'
  actionpack (2.3.4) lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
  actionpack (2.3.4) lib/action_controller/rescue.rb:160:in `perform_action_without_flash'
  actionpack (2.3.4) lib/action_controller/flash.rb:146:in `perform_action'
  actionpack (2.3.4) lib/action_controller/base.rb:532:in `send'
  actionpack (2.3.4) lib/action_controller/base.rb:532:in `process_without_filters'
  actionpack (2.3.4) lib/action_controller/filters.rb:606:in `process'
  vendor/plugins/lackac-render_component-07ba109/lib/components.rb:27:in `process_with_components'
  vendor/plugins/lackac-render_component-07ba109/lib/components.rb:88:in `component_response'
  vendor/plugins/lackac-render_component-07ba109/lib/components.rb:60:in `render_component_as_string'
  vendor/plugins/lackac-render_component-07ba109/lib/components.rb:120:in `component_logging'
  vendor/plugins/lackac-render_component-07ba109/lib/components.rb:59:in `render_component_as_string'
  vendor/plugins/lackac-render_component-07ba109/lib/components.rb:33:in `__send__'
  vendor/plugins/lackac-render_component-07ba109/lib/components.rb:33:in `render_component'
  vendor/plugins/active_scaffold/lib/extensions/action_view_rendering.rb:59:in `render'
  app/views/dashboard/index.rhtml:69:in `_run_rhtml_app47views47dashboard47index46rhtml'
  actionpack (2.3.4) lib/action_view/renderable.rb:34:in `send'
  actionpack (2.3.4) lib/action_view/renderable.rb:34:in `render'
  actionpack (2.3.4) lib/action_view/base.rb:301:in `with_template'
  actionpack (2.3.4) lib/action_view/renderable.rb:30:in `render'
  actionpack (2.3.4) lib/action_view/template.rb:199:in `render_template'
  actionpack (2.3.4) lib/action_view/base.rb:260:in `render_without_active_scaffold'
  vendor/plugins/active_scaffold/lib/extensions/action_view_rendering.rb:61:in `render'
  actionpack (2.3.4) lib/action_view/base.rb:343:in `_render_with_layout'
  actionpack (2.3.4) lib/action_view/base.rb:257:in `render_without_active_scaffold'
  vendor/plugins/active_scaffold/lib/extensions/action_view_rendering.rb:61:in `render'
  actionpack (2.3.4) lib/action_controller/base.rb:1250:in `render_for_file'
  actionpack (2.3.4) lib/action_controller/base.rb:945:in `render_without_benchmark'
  actionpack (2.3.4) lib/action_controller/benchmarking.rb:51:in `render_without_active_scaffold'
  activesupport (2.3.4) lib/active_support/core_ext/benchmark.rb:17:in `ms'
  /opt/ror/ruby-ee-1.8.7-2010.01/lib/ruby/1.8/benchmark.rb:308:in `realtime'
  activesupport (2.3.4) lib/active_support/core_ext/benchmark.rb:17:in `ms'
  actionpack (2.3.4) lib/action_controller/benchmarking.rb:51:in `render_without_active_scaffold'
  vendor/plugins/active_scaffold/lib/extensions/action_controller_rendering.rb:13:in `render'
  actionpack (2.3.4) lib/action_controller/base.rb:1326:in `default_render'
  actionpack (2.3.4) lib/action_controller/base.rb:1332:in `perform_action_without_filters'
  actionpack (2.3.4) lib/action_controller/filters.rb:617:in `call_filters'
  actionpack (2.3.4) lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
  actionpack (2.3.4) lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
  activesupport (2.3.4) lib/active_support/core_ext/benchmark.rb:17:in `ms'
  /opt/ror/ruby-ee-1.8.7-2010.01/lib/ruby/1.8/benchmark.rb:308:in `realtime'
  activesupport (2.3.4) lib/active_support/core_ext/benchmark.rb:17:in `ms'
  actionpack (2.3.4) lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
  actionpack (2.3.4) lib/action_controller/rescue.rb:160:in `perform_action_without_flash'
  actionpack (2.3.4) lib/action_controller/flash.rb:146:in `perform_action'
  actionpack (2.3.4) lib/action_controller/base.rb:532:in `send'
  actionpack (2.3.4) lib/action_controller/base.rb:532:in `process_without_filters'
  actionpack (2.3.4) lib/action_controller/filters.rb:606:in `process'
  actionpack (2.3.4) lib/action_controller/base.rb:391:in `process'
  actionpack (2.3.4) lib/action_controller/base.rb:386:in `call'
  actionpack (2.3.4) lib/action_controller/routing/route_set.rb:437:in `call'
  actionpack (2.3.4) lib/action_controller/dispatcher.rb:87:in `dispatch'
  actionpack (2.3.4) lib/action_controller/dispatcher.rb:121:in `_call'
  actionpack (2.3.4) lib/action_controller/dispatcher.rb:130
  activerecord (2.3.4) lib/active_record/query_cache.rb:29:in `call'
  activerecord (2.3.4) lib/active_record/query_cache.rb:29:in `call'
  activerecord (2.3.4) lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
  activerecord (2.3.4) lib/active_record/query_cache.rb:9:in `cache'
  activerecord (2.3.4) lib/active_record/query_cache.rb:28:in `call'
  activerecord (2.3.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
  rack (1.0.1) lib/rack/head.rb:9:in `call'
  rack (1.0.1) lib/rack/methodoverride.rb:24:in `call'
  actionpack (2.3.4) lib/action_controller/params_parser.rb:15:in `call'
  actionpack (2.3.4) lib/action_controller/session/abstract_store.rb:122:in `call'
  activesupport (2.3.4) lib/active_support/cache/strategy/local_cache.rb:24:in `call'
  actionpack (2.3.4) lib/action_controller/failsafe.rb:26:in `call'
  rack (1.0.1) lib/rack/lock.rb:11:in `call'
  rack (1.0.1) lib/rack/lock.rb:11:in `synchronize'
  rack (1.0.1) lib/rack/lock.rb:11:in `call'
  actionpack (2.3.4) lib/action_controller/dispatcher.rb:114:in `call'
  actionpack (2.3.4) lib/action_controller/reloader.rb:34:in `run'
  actionpack (2.3.4) lib/action_controller/dispatcher.rb:108:in `call'
  /opt/ror/passenger/lib/phusion_passenger/rack/request_handler.rb:92:in `process_request'
  /opt/ror/passenger/lib/phusion_passenger/abstract_request_handler.rb:207:in `main_loop'
  /opt/ror/passenger/lib/phusion_passenger/railz/application_spawner.rb:400:in `start_request_handler'
  /opt/ror/passenger/lib/phusion_passenger/railz/application_spawner.rb:351:in `handle_spawn_application'
  /opt/ror/passenger/lib/phusion_passenger/utils.rb:184:in `safe_fork'
  /opt/ror/passenger/lib/phusion_passenger/railz/application_spawner.rb:349:in `handle_spawn_application'
  /opt/ror/passenger/lib/phusion_passenger/abstract_server.rb:352:in `__send__'
  /opt/ror/passenger/lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
  /opt/ror/passenger/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
  /opt/ror/passenger/lib/phusion_passenger/abstract_server.rb:163:in `start'
  /opt/ror/passenger/lib/phusion_passenger/railz/application_spawner.rb:209:in `start'
  /opt/ror/passenger/lib/phusion_passenger/spawn_manager.rb:262:in `spawn_rails_application'
  /opt/ror/passenger/lib/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add'
  /opt/ror/passenger/lib/phusion_passenger/spawn_manager.rb:256:in `spawn_rails_application'
  /opt/ror/passenger/lib/phusion_passenger/abstract_server_collection.rb:80:in `synchronize'
  /opt/ror/passenger/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
  /opt/ror/passenger/lib/phusion_passenger/spawn_manager.rb:255:in `spawn_rails_application'
  /opt/ror/passenger/lib/phusion_passenger/spawn_manager.rb:154:in `spawn_application'
  /opt/ror/passenger/lib/phusion_passenger/spawn_manager.rb:287:in `handle_spawn_application'
  /opt/ror/passenger/lib/phusion_passenger/abstract_server.rb:352:in `__send__'
  /opt/ror/passenger/lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
  /opt/ror/passenger/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
  /opt/ror/passenger/bin/passenger-spawn-server:61

Original comment by Scott.R....@gmail.com on 20 Sep 2010 at 2:14

GoogleCodeExporter commented 9 years ago
Why so many people think they are using 1.2RC1? It's a very old version which 
only work for rails < 2.1. As is explained in wiki, for rails 2.3 you only can 
use rails-2.3 branch and master branch.

You AS copy is outdated, because line 204 in finder.rb doesn't call count 
method. Is the wrong SQL in the log?

Original comment by sergio.c...@gmail.com on 21 Sep 2010 at 8:56

GoogleCodeExporter commented 9 years ago
I would venture to guess that the resaon so many people think they're using 
1.2RC1 is that the latest entry in the CHANGELOG file included in the baseline, 
at least for the baseline that I downloaded on March 18, 2010, is the 1.2RC1 
entry.  Before you dismiss this completely as a compatibility issue, which I 
don't think it is considering, as I said, I pulled the latest baseline as of 
March 18th of this year.  Could you please explain how to determine which 
version of AS that I'm running?

Original comment by Scott.R....@gmail.com on 21 Sep 2010 at 2:24

GoogleCodeExporter commented 9 years ago
We removed versioning because AS development was very slow so we only made 
branches named as rails version. Now we should add versioning again, probably 
when we release a rails3 version.

Probably your version is rails-2.3 branch, because count call is near line 204 
now. I don't know what is parameterized and I don't know if code must change to 
use parameterized configuration. However AS uses ActiveRecord to build queries, 
so bug can be in ActiveScaffold, ActiveRecord or DB2 adapter.

Is wrong SQL query displayed in the log? What is paramarray? Is it a field in 
some table? A virtual field you added to AS?

I suppose you are loading index view for a controller, without nesting, 
searching or adding parameters to the URL. Have you defined 
conditions_for_collection?

Original comment by sergio.c...@gmail.com on 22 Sep 2010 at 8:07

GoogleCodeExporter commented 9 years ago
The parameterized configuration is described in the following article.
http://www.ibm.com/developerworks/data/library/techarticle/dm-1001db2rubyonrails
apps/index.html

The SQL is auto generated (by AS, AR or DB2) so I don't know what paramarray is 
although I can tell you it is not a column in the table (niether is 
sqlSegment).  Here is the SQL from the log file.

SELECT count(*) AS count_all FROM <table_name> WHERE (<table_name>.paramArray 
IN (?,?,?) AND <table_name>.sqlSegment = ?)

Yes, in this instance I'm loading the index view for a controller and yes, I 
have defined conditions_for_collection.  Please note that I get the same error 
for even the simplest of AS implementations with this parameterized 
configuration.

Original comment by Scott.R....@gmail.com on 1 Oct 2010 at 2:30

GoogleCodeExporter commented 9 years ago
Please, add a debugger line before line 204 in finder.rb and post arguments for 
klass.count

Original comment by sergio.c...@gmail.com on 4 Oct 2010 at 7:51

GoogleCodeExporter commented 9 years ago
*** finder options hash ***
key = include value =
key = joins value =
key = conditions value = sqlSegment(<table name>.maf_rowid IN (select maf_rowid 
from <schema name>.<table name> where app_user_id = ?) and <table 
name>.reporting_period_id = ? and (UPPER(calc) != 'YES' or calc IS NULL)) AND 
(<table name>.fiscal_yr_id = ?)paramArray10000164124
key = order value = <table name>.maf_lineno ASC, <table name>.maf_split ASC

*** options hash ***
key = per_page value = 15
key = page value = 1
key = count_includes value =
key = pagination value = true
key = sorting value = #<ActiveScaffold::DataStructures::Sorting:0xbc18238>

Original comment by Scott.R....@gmail.com on 4 Oct 2010 at 4:30

GoogleCodeExporter commented 9 years ago
I suppose do you get that finder options hash due to your 
conditions_for_collection. Can you post that method too? Can you try to execute 
in console klass.count with that conditions?

Anyway, if it's failing with a controller without conditions_for_collection, it 
would be better to debug with that controller. I only can give you indications 
to debug it because I don't have DB2 neither experience in replicate your setup.

Original comment by sergio.c...@gmail.com on 5 Oct 2010 at 7:56