On Sábado, 17 de Octubre de 2009 00:38:06 Andrew Selder escribió:
> I'm wondering why displaying the list view in AS, the count SQL
> generated includes all associations in the list view.
>
> I know I can override this with config.list.count_includes, but it
> seems to me that the default should be to include no associations in
> the count, rather than all of them.
>
> From what I can tell in the 99% case, the addition of the includes to
> the count does nothing but slow down the query.
>
> SELECT count(DISTINCT `a`.id) AS count_all FROM `a`  LEFT OUTER JOIN
> `b` ON b.a_id = a.id
> will return the same value as
> SELECT count(*) FROM a
>  in every case when id is a primary key on a

They are included to simplify setting conditions in association's tables in 
the conditions_for_collection method. Changing this will break applications 
which define conditions_for_collection and rely in having count_includes filled 
with associations. I think it would break controllers which search in 
assocations too, or nested scaffolds.

Maybe can be autofilled with all associations only when conditions aren't nil. 
In this way behaviour shouldn't be changed for nested scaffolds, when you set 
config.list.count_includes, define conditions_for_collection or search in 
associations.

-- 
Sergio Cambra .:: entreCables S.L. ::.
Mariana Pineda 23, 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) [email protected]


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to