Forum: Ruby on Rails ActiveRecord 1.13.0 + MySql + Linux

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E71a422612298e95fa7c21212594c2d0?d=identicon&s=25 etienne.durand (Guest)
on 2005-11-12 12:50
(Received via mailing list)
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:in
`execute'
/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:in
`select_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:in
`find'
#{RAILS_ROOT}/app/models/ticket.rb:37:in `find_last_posted'
#{RAILS_ROOT}/app/controllers/category_controller.rb:10:in `view'
This topic is locked and can not be replied to.