ActiveRecord ArgumentError: negative row size (or too large)

I have been working with this for several days. Here's the ActiveRecord error and application trace.

ArgumentError: negative string size (or size too big): EXEC sp_executesql N'SELECT [ops_jobs_join].* FROM [ops_jobs_join] WHERE (work_center_id = N''M*1053'' OR work_center_id = N''M*1035'' OR work_center_id = N''M*1037'' OR work_center_id = N''M*1036'') AND (status != N''C'') AND (start_date != N'''') AND (start_date >= N''20120516'') AND (comp_date <= N''20120527'') AND (work_order NOT LIKE N''LA%'') ORDER BY work_center_id ASC, start_date ASC, starting_shift_num ASC, status ASC, priority ASC, comp_date ASC, ending_shift_num ASC, due_date ASC, sequence_number ASC' 

It turns out, if I call Op.all, I get this error:

ActiveRecord ArgumentError: negative row size (or size too large)

If I ignore the column used, which may contain Unicode characters, it works fine. All data is stored in the database without problems, but for some reason rails3 does not have it.

In some cases, sentences return records, while others lead to the same error:

activeerecord-sqlserver-adapter (3.2.4) lib / active_record / connection_adapters / sqlserver / database_statements.rb: 421: in `fetch_all '

It looks like these two posts:

It seems that the solution in the first post is to change the gem, which I would like to avoid.

I looked at my desk and I don't think that I use keywords as field names.

I use other queries like this and they work fine. The only difference is the values ​​that I use in the where clause (work_center_id = N``M * 1053 '').

+7
source share
1 answer

The default encoding of Rails for data management is UTF8, you also need to use this encoding in your database. Change it, and everything should be fine.

+1
source

All Articles