#4 new
Hector E. Gomez Morales

#2006 with_scope & :having option bug with 2.3 RC1

Reported by Hector E. Gomez Morales | April 9th, 2009 @ 03:10 PM

I think the problem is SQLite3.

If we look to the query it has some ambiguety because it is aliasing SUM(salary) to salary but the table has a salary column too. In MySQL it even outputs this message:

1052 Column 'salary' in group statement is ambiguous

Output doing the query from the sqlite console:


sqlite> SELECT SUM(salary) AS salary FROM developers GROUP BY salary HAVING SUM(salary) > 10000;
SQL error: aggregate functions are not allowed in the GROUP BY clause

Output doing the query but qualifying the field in the GROUP BY clause:


sqlite> SELECT SUM(salary) AS salary FROM developers GROUP BY developers.salary HAVING SUM(salary) > 10000;
80000
800000
150000

I think there was a change from 3.4.2 (used in ci.rubyonrails.org) to 3.6.12 (my version) where the default qualification now locks to SUM(salary) when before it locked to developers.salary

No comments found

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

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

Proposal for the implementation of ActiveEncoding library that will make transparent the manipulation of string of different encodings (compatible and not compatible).

People watching this ticket

Pages