Created
February 5, 2014 14:34
-
-
Save vanderhoorn/8824862 to your computer and use it in GitHub Desktop.
Test for Arel bug in https://github.com/rails/arel/pull/243
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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