0

使用 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
                ...

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

4

1 回答 1

0

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

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

这是维基百科的相关摘录:

今天的 ODBC

ODBC remains largely universal today, with drivers available for most platforms and most databases. It is not uncommon to find ODBC drivers for database engines that are meant to be embedded, like SQLite, as a way to allow existing tools to act as front-ends to these engines for testing and debugging. However, the rise of thin client computing using HTML as an intermediate format has reduced the need for ODBC. Many web development platforms contain direct links to target databases - MySQL being particularly common. In these scenarios, there is no direct client-side access nor multiple client software systems to support, everything goes through the programmer-supplied HTML application. The virtualization that ODBC offers is no longer a strong requirement, and development of ODBC is no longer as active as it once was.

于 2013-07-13T18:50:43.880 回答