This project is archived and is in readonly mode.

#2823 incomplete
Joshua Krall

Calculations break with multi-column :select argument

Reported by Joshua Krall | June 22nd, 2009 @ 08:43 AM | in 3.0.6

I ran into a problem with geokit and will_paginate... that I tracked down to a bad interaction between the :select option and calculation methods.

It boils down to a simple case that looks like this:

Account.scoped(:select => "credit_limit, COS(credit_limit) as cosine_of_credit_limit").count

This case demonstrates what geokit adds to the :select argument, but it also fails if you do something as simple as :select=>'a,b'

I'm uploading a new patch to fix this, by splitting the column on commas and taking the first column for the COUNT() directive. So, :select=>'a,b' turns into "SELECT COUNT(a) as count_a ..."

All tests pass, but take a look and see if you find anything wrong here. Thanks!

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages