A small modification at ActiveRecord's calculations.rb

Hello,

I'm not sure if this is the right channel to write this message. but
by adding

line 208 : sql << ") AS #{aggregate_alias}_subquery" if use_workaround

More legitimate sql code is generated, and a bug for the newly
developed and distributed MonetDB adapter is solved.

MonetDB prints this message :

!subquery table reference needs alias, use AS xxx in: "select count(*)
as count_all from (select distinct "accounts".id from "accounts" left
outer join "companies" on "companies".id = "accounts".firm_id and
"companies"."type" = 'Firm' where (companies.id > 1) );"

Could this modification be added in the ActiveRecord code?

Thanks,
Michalis Polakis

Hello,

I'm not sure if this is the right channel to write this message. but
by adding

line 208 : sql << ") AS #{aggregate_alias}_subquery" if use_workaround

More legitimate sql code is generated, and a bug for the newly
developed and distributed MonetDB adapter is solved.

MonetDB prints this message :

!subquery table reference needs alias, use AS xxx in: "select count(*)
as count_all from (select distinct "accounts".id from "accounts" left
outer join "companies" on "companies".id = "accounts".firm_id and
"companies"."type" = 'Firm' where (companies.id > 1) );"

Could this modification be added in the ActiveRecord code?

Hi Michalis,

You're in the right place for this sort of stuff :slight_smile:
Best thing to do is to stick a patch up at rails.lighthouseapp.com
(and then post the link to that ticket here)

Fred

It is ticket number : 796
http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/796
thanks

It is ticket number : 796
http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/796
thanks

Hi Michalis,

you should really put it in the form of a patch file, so everyone
knows exactly what you're talking about. I assume that this doesn't
break any tests for any of the other databases?
There's a quick howto on patches here: http://rails.lighthouseapp.com/projects/8994/sending-patches

Fred

Hi Frederick,

sorry for not doing it the proper way, I really didn't have time to
devote in it.
However Tom Ward created a patch for it, and it has been already
commited by Michael Koziarski.
http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/796
As far as I am aware, it shouldn't create any problem; it is more
legitimate sql code anyway. I haven't tested it against other adapters
though, and at the moment I can't really remember which
test generated such a query.

Michalis