<?xml version="1.0" encoding="UTF-8" standalone="yes"?><oembed><version><![CDATA[1.0]]></version><provider_name><![CDATA[Software is Crap]]></provider_name><provider_url><![CDATA[https://davmac.wordpress.com]]></provider_url><author_name><![CDATA[davmac]]></author_name><author_url><![CDATA[https://davmac.wordpress.com/author/davmac/]]></author_url><title><![CDATA[Rails devs: &#8220;we don&#8217;t know how to fix it, therefore it&#8217;s not a&nbsp;bug.&#8221;]]></title><type><![CDATA[link]]></type><html><![CDATA[<p>As per title:</p>
<p><a title="https://github.com/rails/rails/issues/16291" href="https://github.com/rails/rails/issues/16291">https://github.com/rails/rails/issues/16291</a></p>
<p>I really don&#8217;t know whether to laugh or cry. It would certainly be funny if</p>
<ol>
<li>I didn&#8217;t actually have to use Rails</li>
<li>I hadn&#8217;t spent several hours debugging the issue &#8211;</li>
<li>&#8211; and producing an executable test case, like they asked me to</li>
<li>&#8211; which required setting up a whole new Ruby environment, because the test case template didn&#8217;t want to work with JRuby which is what we normally use.</li>
</ol>
<p>This response is just a joke:</p>
<blockquote><p><code>empty?</code> removed the select values because it needs to call <code>count(:all)</code> or it will fail in some conditions.</p></blockquote>
<p>I&#8217;d love some more specifics on why it needs to call count(:all) and what these alleged fail conditions are. In any case, why does adding &#8216;count(all)&#8217; require throwing the other select values away? Just use the original query as a subquery and count the result rows. Or, don&#8217;t perform a count at all &#8211; just test whether the query returns any results. I mean this is <em>not</em> a difficult problem. Are the Rails developers really this incompetent?<br />
Also, does the following code (from activerecord) really make sense to anyone?</p>
<pre><code>  select_values = [
    operation_over_aggregate_column(
      aggregate_column(column_name),
      operation,
      distinct).as(aggregate_alias)
  ]
  select_values += select_values unless having_values.empty?

  select_values.concat group_fields.zip(group_aliases).map { |field,aliaz|
    if field.respond_to?(:as)
      field.as(aliaz)
    else
      "#{field} AS #{aliaz}"
    end
  }

  relation = except(:group)
  relation.group_values  = group
  relation.select_values = select_values
</code></pre>
<p>I mean, keeping in mind that I know the purpose is to build up an SQL query, most of it makes a hazy sort of sense. But what is <em>this</em> line:</p>
<pre><code>  select_values += select_values unless having_values.empty?
</code></pre>
<p>I just can&#8217;t figure out for the life of me why you&#8217;d ever need to list every column in a &#8216;select&#8217; statement twice, and why there being any &#8216;having&#8217; clause would remove this need. And the real clincher is, there&#8217;s not a <em>single comment</em> in the code to explain why this would be necessary.</p>
<p>I&#8217;m starting to feel like using the Rails framework was a mistake.</p>
<p><strong>Update 3/1/2015:</strong> Blergh, bug closed due to inactivity (they couldn&#8217;t be arsed fixing it &#8211; which could have been done with a simple documentation update &#8211; and so now the bug disappears). I&#8217;m done with reporting bugs to the Rails devs. If I encounter a serious bug in the future, I&#8217;ll fork and fix it myself. Code quality and general process in Rails is just awful.</p>
]]></html></oembed>