Skip to content
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.

Breaking select(...).distinct #398

Open
ioquatix opened this issue Sep 2, 2015 · 1 comment
Open

Breaking select(...).distinct #398

ioquatix opened this issue Sep 2, 2015 · 1 comment

Comments

@ioquatix
Copy link

ioquatix commented Sep 2, 2015

Work fine without squeel..

[2] pry(main)> GeoZone::UserUpdate.select(:user_id).distinct.count
=> 14261
[3] pry(main)> require 'squeel'
=> true
[4] pry(main)> GeoZone::UserUpdate.select(:user_id).distinct.count
ActiveRecord::StatementInvalid: Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') FROM `user_update` WHERE `user_update`.`latitude` IS NOT NULL AND `user_update' at line 1: SELECT DISTINCT COUNT(DISTINCT ) FROM `user_update` WHERE `user_update`.`latitude` IS NOT NULL AND `user_update`.`longitude` IS NOT NULL
from /home/samuel/.rvm/gems/ruby-2.1.2/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:305:in `query'

Distinct clause is empty for some reason: SELECT DISTINCT COUNT(DISTINCT )

@gmcnaughton
Copy link

I think this is the same issue as #355

FWIW, we're seeing this same bug in Rails 4.2.7 and squeel 1.2.3

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants