本文介绍了ActiveRecord的:: StatementInvalid:引发ArgumentError:负字符串大小(或尺寸过大):SELECT * FROM [店]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图实例太多内存中的对象时收到此错误。这一个Rails 2.3.x应用程序,使用SQL Server作为数据库。
>> Shop.count
=> 14111
>> Shop.all
ActiveRecord的:: StatementInvalid:引发ArgumentError:负字符串大小(或尺寸过大):SELECT * FROM [店]
从/Users/lunks/.rvm/gems/ree-1.8.7-2011.03@ums/gems/activerecord-2.3.14/的lib / active_record / connection_adapters / abstract_adapter.rb:227:在'登录'
从/Users/lunks/.rvm/ gems/ree-1.8.7-2011.03@ums/gems/activerecord-sqlserver-adapter-2.3.24/lib/active_record/connection_adapters/sqlserver_adapter.rb:1004:in `raw_select
从/Users/lunks/.rvm/gems/ree-1.8.7-2011.03@ ums/gems/activerecord-sqlserver-adapter-2.3.24/lib/active_record/connection_adapters/sqlserver_adapter.rb:965:in '选择'
从/Users/lunks/.rvm/gems/ree-1。 8.7-2011.03@ums/gems/activerecord-2.3.14/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache
从/Users/lunks/.rvm /gems/ree-1.8.7-2011.03@ums/gems/activerecord-2.3.14/lib/active_record/connection_adapters/abstract/query_cache.rb:62:in `SELECT_ALL
从/用户/ LU nks/.rvm/gems/ree-1.8.7-2011.03@ums/gems/activerecord-2.3.14/lib/active_record/base.rb:665:在'的find_by_sql
从/Users/lunks/.rvm/gems/ree-1.8.7-2011.03@ums/gem S / ActiveRecord的-2.3.14 / lib中/ active_record / base.rb:1582:在'find_every
从/Users/lunks/.rvm/gems/ree-1.8.7-2011.03@ums/gems/activerecord-2.3.14/lib/active_record/base.rb:619:in '发现'
从/Users/lunks/.rvm/gems/ree-1.8.7-2011.03@ums/ge MS / ActiveRecord的-2.3.14 / lib中/ active_record / base.rb:639:在'所有'
从(IRB):3`
解决方案
解决不断变化的ODBC宝石需要,而不是 ODBC $ C到
odbc_utf8
$ C>。归类是Latin1的,虽然。 :P
I'm getting this error when trying to instantiate too much objects in memory. This a Rails 2.3.x app, with SQL Server as the database.
>> Shop.count
=> 14111
>> Shop.all
ActiveRecord::StatementInvalid: ArgumentError: negative string size (or size too big): SELECT * FROM [shop]
from /Users/lunks/.rvm/gems/ree-1.8.7-2011.03@ums/gems/activerecord-2.3.14/ lib/active_record/connection_adapters/abstract_adapter.rb:227:in `log'
from /Users/lunks/.rvm/ gems/ree-1.8.7-2011.03@ums/gems/activerecord-sqlserver-adapter-2.3.24/lib/active_record/connection_adapters/sqlserver_adapter.rb:1004:in `raw_select'
from /Users/lunks/.rvm/gems/ree-1.8.7-2011.03@ ums/gems/activerecord-sqlserver-adapter-2.3.24/lib/active_record/connection_adapters/sqlserver_adapter.rb:965:in `select'
from /Users/lunks/.rvm/gems/ree-1. 8.7-2011.03@ums/gems/activerecord-2.3.14/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache'
from /Users/lunks/.rvm /gems/ree-1.8.7-2011.03@ums/gems/activerecord-2.3.14/lib/active_record/connection_adapters/abstract/query_cache.rb:62:in `select_all'
from /Users/lu nks/.rvm/gems/ree-1.8.7-2011.03@ums/gems/activerecord-2.3.14/lib/active_record/base.rb:665:in `find_by_sql'
from /Users/lunks/.rvm/gems/ree-1.8.7-2011.03@ums/gem s/activerecord-2.3.14/lib/active_record/base.rb:1582:in `find_every'
f rom /Users/lunks/.rvm/gems/ree-1.8.7-2011.03@ums/gems/activerecord-2.3.14/lib/active_record/base.rb:619:in `find'
from /Users/lunks/.rvm/gems/ree-1.8.7-2011.03@ums/ge ms/activerecord-2.3.14/lib/active_record/base.rb:639:in `all'
from (irb):3`
解决方案
Solved changing ODBC gem require to odbc_utf8
instead of odbc
. The collation is in Latin1, though. :P
这篇关于ActiveRecord的:: StatementInvalid:引发ArgumentError:负字符串大小(或尺寸过大):SELECT * FROM [店]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!