I've been working with this one for a few days. Here's the ActiveRecord error and the 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 string size (or size too big)
If I ignore the column that uses may contain unicode characters it works fine. All the data is being stored in the database without a problem but for some reason rails3 isn't having it.
Some where clauses will return records while others result in the same error:
activerecord-sqlserver-adapter (3.2.4) lib/active_record/connection_adapters/sqlserver/database_statements.rb:421:in `fetch_all'
It's similar to these two posts:
ActiveRecord::StatementInvalid: ArgumentError: negative string size (or size too big): SELECT * FROM [shop]
ActiveRecord doesn't work on one table
It seems like the solution in the first post is to change the gem which I would like to avoid.
I looked at my table and I don't think I'm using any keywords as field names.
I use other queries similar to this one and they work fine. The only difference is the values I use in the where clause (work_center_id = N''M*1053'').
Rails default encoding for manipulates with data is UTF8, you need to use this encoding as well in your database. Change it and all has to be fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With