ActiveRecord 1.13.0 + MySql + Linux


#1

Hi,

Migrating an application from windows to linux, i am experiencing some
query building errors. For non trivial queries, involving parentheses,
the built query contains some extra ‘:’ character.
For instance, if input :conditions is:

is_spam != 1 and is_prohibited !=1 and is_archived !=1 and id in (select
ticket_id from categories_tickets where category_id in (select
category_id from category_ancestors where ancestor_id = 68))

The following code throws an error:
find(:all, :conditions => sql, :order => ‘created_on desc’, :limit =>
page_size, :offset => offset)

throws an error. The log indicates that the query contains some extra
‘:’ :
You have an error in your SQL syntax. Check the manual that corresponds
to your MySQL server version for the right syntax to use near 'select
ticket_id from categories_tickets where category_id in (: SELECT * FROM
tickets WHERE (is_spam != 1 and is_prohibited !=1 and is_archived !=1
and id in (select ticket_id from categories_tickets where category_id in
(select category_id from category_ancestors where ancestor_id = 68)))
ORDER BY created_on desc LIMIT 0, 10

Anybody has experienced this kind of issues?

The error stack is:
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/connection_adapters/abstract_adapter.rb:67:in
log' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/connection_adapters/mysql_adapter.rb:155:inexecute’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/connection_adapters/mysql_adapter.rb:297:in
select' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/connection_adapters/mysql_adapter.rb:143:inselect_all’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/base.rb:447:in
find_by_sql' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/base.rb:411:infind’
#{RAILS_ROOT}/app/models/ticket.rb:37:in find_last_posted' #{RAILS_ROOT}/app/controllers/category_controller.rb:10:inview’