Skip to content

Instantly share code, notes, and snippets.

match cache.entry(sql) {
Occupied(entry) => Ok(entry.get().clone()),
Vacant(entry) => {
let statement = try!(Statement::prepare(&self.raw_connection, entry.key()));
Ok(entry.insert(CachedStatement::new(statement)).clone())
}
}
mod embedded_migrations {
struct EmbeddedMigration {
version: &'static str,
up_sql: &'static str,
};
impl Migration for EmbeddedMigration {
fn version(&self) -> &str {
self.version
}
[master][/tmp/qoiwjefoiqwejfoiqwjfoiqwejfioqewjioqfew] cat ~/.rspec
--colour
--order random
--profile 5
[master][/tmp/qoiwjefoiqwejfoiqwjfoiqwejfioqewjioqfew] ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
[master][/tmp/qoiwjefoiqwejfoiqwjfoiqwejfioqewjioqfew] ber -fd
Randomized with seed 44318
bytes sip farm xx horner fnv
1 55 40 66 66 1000
2 100 74 117 133 1000
4 190 142 222 235 2000
8 363 210 533 470 2666
16 640 347 1000 800 2285
32 1103 307 1684 1280 2000
64 1306 524 2909 2206 1254
128 1600 636 4266 3657 927
256 1729 785 6095 5019 920
scalaVersion := "2.11.6"
libraryDependencies ++= Seq(
"com.chuusai" %% "shapeless" % "2.1.0"
)
def baz(x)
x + yield
end
def bar(&block)
baz(1, &block)
end
def foo(&block)
bar(&block)
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
gem 'sqlite3'
GEMFILE
system 'bundle'
end
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb
index d957bd1..60d3002 100644
--- a/activerecord/lib/active_record/core.rb
+++ b/activerecord/lib/active_record/core.rb
@@ -130,7 +130,7 @@ module ActiveRecord
return super if ids.first.kind_of?(Symbol)
return super if block_given? ||
primary_key.nil? ||
- default_scopes.any? ||
+ !default_scopes.all?(&:cacheable?) ||
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
gem 'sqlite3'
gem 'benchmark/ips'
GEMFILE
system 'bundle'
ENV['BUNDLE_GEMFILE'] = File.expand_path('../../rails/Gemfile', __FILE__)
require_relative '../rails/load_paths'
require 'active_record'
require 'active_support/all'
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Schema.define do
create_table :users, force: true do |t|