aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-03-03 13:08:50 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-03-06 08:12:41 +0900
commita67841eb61f808a965da0d61ea47e2d9810436b0 (patch)
tree0939b4bdf517e277c637d2c2f65ee78e3206f825 /activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
parent91ed21b304c468db8ce9fd830312c151432935d0 (diff)
downloadrails-a67841eb61f808a965da0d61ea47e2d9810436b0.tar.gz
rails-a67841eb61f808a965da0d61ea47e2d9810436b0.tar.bz2
rails-a67841eb61f808a965da0d61ea47e2d9810436b0.zip
Ensure `clear_cache!` clears the prepared statements cache
Since #23461, all adapters supports prepared statements, so that clears the prepared statements cache is no longer database specific. Actually, I struggled to identify the cause of random CI failure in #23461, that was missing `@statements.clear` in `clear_cache!`. This extracts `clear_cache!` to ensure the common concerns in the abstract adapter.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb12
1 files changed, 5 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
index 0ed7f3988d..cb3d34a740 100644
--- a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
@@ -96,8 +96,7 @@ module ActiveRecord
def initialize(connection, logger, connection_options, config)
super(connection, logger, config)
- @active = true
- @statements = StatementPool.new(self.class.type_cast_config_to_integer(config[:statement_limit]))
+ @active = true
configure_connection
end
@@ -156,11 +155,6 @@ module ActiveRecord
@connection.close rescue nil
end
- # Clears the prepared statements cache.
- def clear_cache!
- @statements.clear
- end
-
def truncate(table_name, name = nil)
execute "DELETE FROM #{quote_table_name(table_name)}", name
end
@@ -613,6 +607,10 @@ module ActiveRecord
Arel::Visitors::SQLite.new(self)
end
+ def build_statement_pool
+ StatementPool.new(self.class.type_cast_config_to_integer(@config[:statement_limit]))
+ end
+
def configure_connection
execute("PRAGMA foreign_keys = ON", "SCHEMA")
end