Method: ActiveRecord::ConnectionAdapters::SQLite2Adapter#execute

Defined in:
lib/active_record/connection_adapters/sqlite_adapter.rb

#execute(sql, name = nil) ⇒ Object

SQLite 2 does not support COUNT(DISTINCT) queries:

select COUNT(DISTINCT ArtistID) from CDs;

In order to get the number of artists we execute the following statement

SELECT COUNT(ArtistID) FROM (SELECT DISTINCT ArtistID FROM CDs);


373
374
375
# File 'lib/active_record/connection_adapters/sqlite_adapter.rb', line 373

def execute(sql, name = nil) #:nodoc:
  super(rewrite_count_distinct_queries(sql), name)
end