# ActiveRecord::Calculations::ClassMethods\>\>count doesn't behave as in Rails 1.1.6

**URL:** <https://www.ruby-forum.com/t/activerecord-classmethods-count-doesnt-behave-as-in-rails-1-1-6/150429>\
**Category:** Rails\
**Created:** [October 8, 2008, 2:44pm UTC](https://www.ruby-forum.com/t/activerecord-classmethods-count-doesnt-behave-as-in-rails-1-1-6/150429 "2008-10-08T14:44:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![clemens](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/df788c/32.png) [@clemens](https://www.ruby-forum.com/u/clemens)\
**Post date:** [October 8, 2008, 2:44pm UTC](https://www.ruby-forum.com/t/activerecord-classmethods-count-doesnt-behave-as-in-rails-1-1-6/150429/1 "2008-10-08T14:44:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![clemens](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/df788c/32.png) [@clemens](https://www.ruby-forum.com/u/clemens)\
**Post date:** [October 8, 2008, 2:49pm UTC](https://www.ruby-forum.com/t/activerecord-classmethods-count-doesnt-behave-as-in-rails-1-1-6/150429/2 "2008-10-08T14:49:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![clemens](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/df788c/32.png) [@clemens](https://www.ruby-forum.com/u/clemens)\
**Post date:** [October 8, 2008, 2:49pm UTC](https://www.ruby-forum.com/t/activerecord-classmethods-count-doesnt-behave-as-in-rails-1-1-6/150429/3 "2008-10-08T14:49:02Z")

</div>

On Oct 8, 8:44 pm, fx3000se [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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])

---

<div class="post-metadata">

**Author:** ![clemens](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/df788c/32.png) [@clemens](https://www.ruby-forum.com/u/clemens)\
**Post date:** [October 8, 2008, 2:51pm UTC](https://www.ruby-forum.com/t/activerecord-classmethods-count-doesnt-behave-as-in-rails-1-1-6/150429/4 "2008-10-08T14:51:24Z")

</div>

thx 🙂
