Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@such
Created December 26, 2013 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save such/8136555 to your computer and use it in GitHub Desktop.
Save such/8136555 to your computer and use it in GitHub Desktop.
Demonstrates that update_all behavior is different between mysql and the other databases
# Activate the gem you are reporting the issue against.
gem 'activerecord', '4.0.2'
gem 'pg'
require 'active_record'
require 'minitest/autorun'
require 'logger'
ActiveRecord::Base.establish_connection(adapter: 'postgresql', username: 'user', password: 'pass', database: 'test')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :posts do |t|
t.integer :author_id
t.string :author_stuff
end
create_table :authors do |t|
t.string :stuff
end
end
class Post < ActiveRecord::Base
belongs_to :author
end
class Author < ActiveRecord::Base
end
class BugTest < Minitest::Unit::TestCase
def test_update_all
Post.joins(:author).update_all('author_stuff = authors.stuff')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment