diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb index 7f7e723419..e016a6f032 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb @@ -505,12 +505,12 @@ module ActiveRecord # Result will have following sample string # CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, # "password_digest" varchar COLLATE "NOCASE"); - result = exec_query(sql, "SCHEMA").first + result = query_value(sql, "SCHEMA") if result # Splitting with left parentheses and discarding the first part will return all # columns separated with comma(,). - columns_string = result["sql"].split("(", 2).last + columns_string = result.split("(", 2).last columns_string.split(",").each do |column_string| # This regex will match the column name and collation type and will save diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index ffe034cb8e..1d0fe635a8 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -367,14 +367,12 @@ module ActiveRecord arel = query.arel end - result = connection.select_one(arel, nil) + size, timestamp = connection.select_rows(arel, nil).first - if result + if size column_type = klass.type_for_attribute(timestamp_column) - timestamp = column_type.deserialize(result["timestamp"]) - size = result["size"] + timestamp = column_type.deserialize(timestamp) else - timestamp = nil size = 0 end end diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index c1062a390c..820136842f 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -316,7 +316,7 @@ module ActiveRecord relation = construct_relation_for_exists(conditions) - skip_query_cache_if_necessary { connection.select_one(relation.arel, "#{name} Exists?") } ? true : false + skip_query_cache_if_necessary { connection.select_rows(relation.arel, "#{name} Exists?").size == 1 } end # This method is called whenever no records are found with either a single @@ -416,8 +416,8 @@ module ActiveRecord relation = relation.except(:select).select(values).distinct! - id_rows = skip_query_cache_if_necessary { @klass.connection.select_all(relation.arel, "SQL") } - id_rows.map { |row| row[primary_key] } + id_rows = skip_query_cache_if_necessary { @klass.connection.select_rows(relation.arel, "SQL") } + id_rows.map(&:last) end def using_limitable_reflections?(reflections)