Skip to content

Instantly share code, notes, and snippets.

@vanderhoorn
Created February 5, 2014 14:34
Show Gist options
  • Save vanderhoorn/8824862 to your computer and use it in GitHub Desktop.
Save vanderhoorn/8824862 to your computer and use it in GitHub Desktop.
gem 'rails', '4.0.2'
require 'active_record'
require 'logger'
# Print out what version we're running
# 4.0.2
puts "Active Record #{ActiveRecord::VERSION::STRING}"
# 4.0.1
puts "Arel #{Arel::VERSION}"
# Connect to a PostgreSQL database
ActiveRecord::Base.establish_connection(
:adapter => 'postgresql',
:database => 'rails-arel-update_all-bug'
)
# Create schema
ActiveRecord::Schema.define do
create_table :foos, :force => true do |t|
t.string :name
end
end
# Create a model
class Foo < ActiveRecord::Base
def self.some_scope
where arel_table[:name].matches('1')
end
end
# reproduce bug
ActiveRecord::Base.logger = Logger.new(STDOUT)
# Works
puts Foo.some_scope.update_all(name: 'bar')
# Raises error
puts Foo.some_scope.order(:name).update_all(name: 'bar')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment