Forum: Ruby on Rails ActiveRecord::Calculations::ClassMethods>>count doesn't behave as in Rails 1.1.6

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.
Bfa7bded551b934e38d141f86281447f?d=identicon&s=25 Clemens Wyss (clemens)
on 2008-10-08 14:44
(Received via mailing list)
ScheduleItem.count(["id = ?", 204])
used to work as expected in Rails 1.1.6, i.e. returning the count of
rows where id = 204 ...
In 2.1.1 I get the error:

"ActiveRecord::StatementInvalid: ActiveRecord::ActiveRecordError: 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 '?204) AS
count_id_204 FROM `schedule_items`' at line 1: SELECT count(id = ?204)
AS count_id_204 FROM `schedule_items` "

Looks like ["id = ?", id] is not evaluated/resolved correctly
resulting in 'id = ?204' instead of 'id = 204'

Bug?

Thx
Clemens
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-10-08 14:49
(Received via mailing list)
On 8 Oct 2008, at 13:44, fx3000se wrote:

> AS count_id_204 FROM `schedule_items` "
>
> Looks like ["id = ?", id] is not evaluated/resolved correctly
> resulting in 'id = ?204' instead of 'id = 204'
>
> Bug?
>
Nope, it changed. This was deprecated in rails  1.2 and removed in 2.0

Fred
23e4fc3add5443f51e55663cfc245d24?d=identicon&s=25 Erol Fornoles (Guest)
on 2008-10-08 14:49
(Received via mailing list)
On Oct 8, 8:44 pm, fx3000se <clemens.w...@gmx.ch> wrote:
>
> Looks like ["id = ?", id] is not evaluated/resolved correctly
> resulting in 'id = ?204' instead of 'id = 204'
>
> Bug?
>
> Thx
> Clemens

ScheduleItem.count(:conditions => ["id = ?", 204])
Bfa7bded551b934e38d141f86281447f?d=identicon&s=25 Clemens Wyss (clemens)
on 2008-10-08 14:51
(Received via mailing list)
thx :-)
This topic is locked and can not be replied to.