升级ActiveRecord ODBC适配器:参数数量错误(3个为2)

时间:2013-07-12 19:56:06

标签: ruby odbc

使用ODBC适配器时出现此错误。可能是我的版本不匹配?看起来我正在使用activerecord-odbc-adapter-2.0和activerecord-3.1.0。

    wrong number of arguments (3 for 2)
    /var/lib/gems/1.9.1/gems/activerecord-odbc-adapter-2.0/lib/active_record/connection_adapters/odbc_adapter.rb:765:in `select_all'
    /var/lib/gems/1.9.1/gems/activerecord-3.1.0/lib/active_record/base.rb:470:in `find_by_sql'
    /var/lib/gems/1.9.1/gems/activerecord-3.1.0/lib/active_record/relation.rb:111:in `to_a'
    /var/lib/gems/1.9.1/gems/activerecord-3.1.0/lib/active_record/relation.rb:15:in `each'
    /usr/local/www/sl-exchange/app/controllers/states_controller.rb:15:in `block in update'
    /var/lib/gems/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
    /var/lib/gems/1.9.1/gems/activerecord-3.1.0/lib/active_record/transactions.rb:208:in `transaction'
    /usr/local/www/sl-exchange/app/controllers/states_controller.rb:12:in `update'
    /usr/local/www/sl-exchange/lib/exchange.rb:97:in `initialize'
    /usr/local/www/sl-exchange/lib/exchange.rb:191:in `new'
    /usr/local/www/sl-exchange/lib/exchange.rb:191:in `<top (required)>'
    /var/lib/gems/1.9.1/gems/daemons-1.1.9/lib/daemons/application.rb:203:in `load'
    /var/lib/gems/1.9.1/gems/daemons-1.1.9/lib/daemons/application.rb:203:in `start_load'
    /var/lib/gems/1.9.1/gems/daemons-1.1.9/lib/daemons/application.rb:298:in `start'
    /var/lib/gems/1.9.1/gems/daemons-1.1.9/lib/daemons/controller.rb:70:in `run'
    /var/lib/gems/1.9.1/gems/daemons-1.1.9/lib/daemons.rb:147:in `block in run'
    /var/lib/gems/1.9.1/gems/daemons-1.1.9/lib/daemons/cmdline.rb:109:in `call'
    /var/lib/gems/1.9.1/gems/daemons-1.1.9/lib/daemons/cmdline.rb:109:in `catch_exceptions'
    /var/lib/gems/1.9.1/gems/daemons-1.1.9/lib/daemons.rb:146:in `run'
    ./data_exchange_preview:15:in `<main>'
    Connection refused - connect(2)
    /usr/lib/ruby/1.9.1/net/smtp.rb:551:in `initialize'
    /usr/lib/ruby/1.9.1/net/smtp.rb:551:in `open'
    /usr/lib/ruby/1.9.1/net/smtp.rb:551:in `block in do_start'
    /usr/lib/ruby/1.9.1/timeout.rb:57:in `timeout'
    /usr/lib/ruby/1.9.1/timeout.rb:87:in `timeout'
    /usr/lib/ruby/1.9.1/net/smtp.rb:551:in `do_start'
    /usr/lib/ruby/1.9.1/net/smtp.rb:525:in `start'
    /usr/lib/ruby/1.9.1/net/smtp.rb:463:in `start'
    /usr/local/www/sl-exchange/app/controllers/controller.rb:21:in `send_notification'
    /usr/local/www/sl-exchange/app/controllers/controller.rb:29:in `handle_exception'
    /usr/local/www/sl-exchange/app/controllers/states_controller.rb:45:in `rescue in update'
    /usr/local/www/sl-exchange/app/controllers/states_controller.rb:4:in `update'
    /usr/local/www/sl-exchange/lib/exchange.rb:97:in `initialize'
    /usr/local/www/sl-exchange/lib/exchange.rb:191:in `new'
    /usr/local/www/sl-exchange/lib/exchange.rb:191:in `<top (required)>'
    /var/lib/gems/1.9.1/gems/daemons-1.1.9/lib/daemons/application.rb:203:in `load'
    /var/lib/gems/1.9.1/gems/daemons-1.1.9/lib/daemons/application.rb:203:in `start_load'
    /var/lib/gems/1.9.1/gems/daemons-1.1.9/lib/daemons/application.rb:298:in `start'
    /var/lib/gems/1.9.1/gems/daemons-1.1.9/lib/daemons/controller.rb:70:in `run'
    /var/lib/gems/1.9.1/gems/daemons-1.1.9/lib/daemons.rb:147:in `block in run'
    /var/lib/gems/1.9.1/gems/daemons-1.1.9/lib/daemons/cmdline.rb:109:in `call'
    /var/lib/gems/1.9.1/gems/daemons-1.1.9/lib/daemons/cmdline.rb:109:in `catch_exceptions'
    /var/lib/gems/1.9.1/gems/daemons-1.1.9/lib/daemons.rb:146:in `run'
    ./data_exchange_preview:15:in `<main>'

以下是我的代码中失败的行:

states_controller.rb:

class StatesController < Controller

def update()    
    ...
        Web::State.transaction do #<-- this is line 12

            nti_states.each do |state| #<-- line 15
                ...

(这只是一个红宝石应用程序。不是rails)如果您需要更多信息,请告诉我。

1 个答案:

答案 0 :(得分:0)

是的,这是一个宝石兼容性问题。从2011年的ActiveRecord 3.1.0开始,select_all采用第三个参数(不可否认最新的)ODBC 2.0适配器不支持,因为它可以追溯到2008年。有关相关的Informix适配器问题,请参阅https://github.com/santana/activerecord-informix-adapter/issues/4

很难相信没有人提供更新的ODBC适配器,也许更难以相信没有人以SO可见的方式抱怨这一点,但也许就是这种情况。哦,强大的力量如何下降。 ; - )

以下是维基百科的相关摘录:

  

今天的ODBC

     

ODBC今天仍然很普遍,大多数驱动程序都可用   平台和大多数数据库。找到ODBC驱动程序并不罕见   对于要嵌入的数据库引擎,如SQLite,作为   允许现有工具充当这些引擎的前端的方法   测试和调试。但是,瘦客户端计算的兴起   使用HTML作为中间格式减少了对ODBC的需求。   许多Web开发平台都包含指向目标的直接链接   数据库 - MySQL特别常见。在这些场景中,有   不是直接的客户端访问,也不是多个客户端软件系统   为了支持,一切都通过程序员提供的HTML   应用。 ODBC提供的虚拟化不再强大   要求,ODBC的开发不再像以前那样活跃   是