Hi Jarrett,

As per previous emails, the problem is that you can't now force it to do a 
query using any particular method.  Associations will cache if you enumerate 
them and so will not behave in that simple way.

Yes we have tests and yes it does show that this kind of change breaks things.  
That's why I'm complaining.

Cheers,
Will


On 28/02/2013, at 15:16 , Jarrett Meyer <jarrettme...@gmail.com> wrote:

> Most other "enterprise-y" languages (esp. Java+Hibernate, .NET+NHibernate, 
> .NET+Entity Framework) reinforce deferred execution of queries: the query is 
> not executed until it is enumerated. This is now the exact same behavior as 
> those platforms.
> 
> Calling .sum() on an association, before you've enumerated, will alter the 
> query to perform a SELECT SUM(...). Obviously, this fails on anything that 
> doesn't exist in the database. If you want to .sum() in memory, you must 
> enumerate the collection first (calling .ToArray() in .NET will do this). I 
> don't know if the author of this deferred execution has experience with these 
> other ORM's, but the behavior is now identical.
> 
> Employee.all vs. Employee.all.to_a is not that big of a deal. And you should 
> expect breaking changes with a major version number. That's why your code is 
> covered by tests, right?
> 
> Signed,
> An-ex-.NET-developer-turned-Rubyist
> 
> --
> Jarrett Meyer
> Email: jarrettme...@gmail.com
> Web: JarrettMeyer.com
> Twitter: @jarrettmeyer
> 
> 
> On Wed, Feb 27, 2013 at 6:09 PM, Will Bryant <will.bry...@gmail.com> wrote:
> That's better than nothing, but #all returns a relation now, which is half 
> the problem (like when you need to sum methods not columns, for eg.).
> 
> 
> On 28/02/2013, at 12:00 , Duncan Beevers <duncanbeev...@gmail.com> wrote:
> 
>> Or all(true)
>> 
>> 
>> On Wed, Feb 27, 2013 at 4:25 PM, Will Bryant <will.bry...@gmail.com> wrote:
>> 
>> On 28/02/2013, at 11:17 , Jon Leighton <j...@jonathanleighton.com> wrote:
>> 
>> > #reload will always run the query.
>> >
>> > If I'm misunderstanding the use case please provide some examples.
>> 
>> Hmm.  But you can't run reload on a scope to get an array - it returns a 
>> relation, which as per previous emails doesn't behave the same.
>> 
>> So are you saying we should use .reload.to_a everywhere instead of #all?
>> 
>> That really seems like a worse API than #all and this is a very common 
>> operation.  Is it really worth changing #all to be nearly useless and have 
>> no direct to do that?
>> 
>> Could we at least have a method that does this, say "query"?
>> 
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Ruby on Rails: Core" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to rubyonrails-core+unsubscr...@googlegroups.com.
>> To post to this group, send email to rubyonrails-core@googlegroups.com.
>> Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>> 
>> 
>> 
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ruby on Rails: Core" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to rubyonrails-core+unsubscr...@googlegroups.com.
>> To post to this group, send email to rubyonrails-core@googlegroups.com.
>> Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-core+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-core+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to