Problem with sum and include

Given these models:

class Intranet < ActiveRecord::Base
has_many :matters
has_many :bills
end

class Matter < ActiveRecord::Base
has_many :bills
belongs_to :intranet
end

class Bill < Entry
belongs_to :intranet
belongs_to :matter
end

These three queries work:

Bill.count(:include => :matter, :conditions => [“matters.number=10711”])

Bill.sum(:amount, :include => :matter, :conditions =>
[“matters.number=10711”])

Intranet.find(1).bills.sum(:amount, :include => :matter, :conditions =>
[“matters.number=10711”])

However, this does not work:

Intranet.find(1).bills.count(:include => :matter, :conditions =>
[“matters.number=10711”])

ActiveRecord::StatementInvalid: Mysql::Error: Unknown table ‘matters’ in
where clause: SELECT count(*) AS count_all FROM entries WHERE
(entries.intranet_id = 1 AND (matters.number=10711)) AND (
(entries.type = ‘Bill’ ) )

It’s ignoring the include. Am I doing something wrong or is this a bug?