<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Pragmatic Forums | Posts in topic 'Possible  bug on find method with :select attribute and aggregate functions...'</title>
    <link>/forums/22/topics/1441.rss</link>
    <language>en-us</language>
    <ttl>60</ttl>
    <item>
      <title>Possible  bug on find method with :select attribute and aggregate functions... posted by Alfredo Rico Moros @ Sun, 23 Nov 2008 19:06:20 +0000</title>
      <description>&lt;p&gt;Apologize, a mistake of copy and paste..&lt;/p&gt;


	&lt;p&gt;This is the output..&lt;/p&gt;


&lt;blockquote&gt;
	&lt;blockquote&gt;
	&lt;p&gt;Specification.find(:all, :select =&amp;gt; &amp;#8216;tolerancia, sum(umbral) as total&amp;#8217;, :group =&amp;gt; &amp;#8216;tolerancia&amp;#8217;)&lt;br /&gt;=&amp;gt; [#&amp;lt;specification tolerancia:&gt;, #&amp;lt;specification tolerancia:&gt;]&lt;/p&gt;

	&lt;/blockquote&gt;



&lt;/blockquote&gt;




	&lt;p&gt;Where is my total field??&lt;/p&gt;</description>
      <pubDate>Sun, 23 Nov 2008 19:06:20 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:22:1441:6315</guid>
      <author>Alfredo Rico Moros</author>
      <link>https://forums.pragprog.com/forums/22/topics/1441</link>
    </item>
    <item>
      <title>Possible  bug on find method with :select attribute and aggregate functions... posted by Alfredo Rico Moros @ Sun, 23 Nov 2008 19:02:54 +0000</title>
      <description>&lt;p&gt;Hi to everyboy.. I need your help in order to know if I get wrong..&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;m using rails 2.2.2 with MySQL 5.0&lt;/p&gt;


	&lt;p&gt;I have this migration file:&lt;/p&gt;


	&lt;p&gt;class CreateSpecifications &amp;lt; ActiveRecord::Migration
  def self.up
    create_table :specifications do |t|
      t.string :tolerancia
      t.integer :umbral&lt;/p&gt;
	&lt;pre&gt;&lt;code&gt;t.timestamps
  end
end&lt;/code&gt;&lt;/pre&gt;


	&lt;pre&gt;&lt;code&gt;def self.down
  drop_table :specifications
end&lt;br /&gt;end&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;I put some data by mean of script/console&lt;br /&gt;Specification.create(:umbral =&amp;gt; 33, :tolerancia =&amp;gt; &amp;#8216;alta&amp;#8217;)&lt;br /&gt;Specification.create(:umbral =&amp;gt; 23, :tolerancia =&amp;gt; &amp;#8216;alta&amp;#8217;)&lt;br /&gt;Specification.create(:umbral =&amp;gt; 12, :tolerancia =&amp;gt; &amp;#8216;baja&amp;#8217;)&lt;br /&gt;Specification.create(:umbral =&amp;gt; 33, :tolerancia =&amp;gt; &amp;#8216;baja&amp;#8217;)&lt;/p&gt;


	&lt;p&gt;Then when I run the following statement&lt;br /&gt;Specification.find(:all, :select =&amp;gt; &amp;#8216;tolerancia, sum(umbral) as total&amp;#8217;, :group =&amp;gt; &amp;#8216;tolerancia&amp;#8217;)&lt;/p&gt;


	&lt;p&gt;I get the following:&lt;br /&gt;[#&amp;lt;specification tolerancia:&gt;, #&amp;lt;specification tolerancia:&gt;]&lt;/p&gt;


	&lt;p&gt;Where is my total field??? How could I get it???&lt;/p&gt;


	&lt;p&gt;Besides, whit the following statement:&lt;br /&gt;&amp;gt;&amp;gt; Specification.find(:first, :select =&amp;gt; &amp;#8216;now() as ahora&amp;#8217;)&lt;br /&gt;=&amp;gt; #&amp;lt;specification&gt;&lt;/p&gt;


	&lt;p&gt;Where is my field &amp;#8216;ahora&amp;#8217;?&lt;/p&gt;


	&lt;p&gt;I have ran this situation on Heroku.com with the same sadly results..&lt;/p&gt;


	&lt;p&gt;Thanks in advanced by your help&amp;#8230;&lt;/p&gt;</description>
      <pubDate>Sun, 23 Nov 2008 19:02:54 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:22:1441:6314</guid>
      <author>Alfredo Rico Moros</author>
      <link>https://forums.pragprog.com/forums/22/topics/1441</link>
    </item>
  </channel>
</rss>
