Created
August 21, 2014 20:36
-
-
Save nathany/5ae1e7bbc7bae86bca20 to your computer and use it in GitHub Desktop.
Test case for bug in Rails 4.0.10.rc
This file contains hidden or 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
# Activate the gem you are reporting the issue against. | |
# gem 'activerecord', '4.0.9' # works | |
gem 'activerecord', '4.0.10.rc1' | |
# gem 'activerecord', '4.1.5' # works | |
# gem 'activerecord', '4.1.6.rc1' | |
gem 'pg' | |
require 'active_record' | |
require 'minitest/autorun' | |
require 'logger' | |
# Ensure backward compatibility with Minitest 4 | |
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test) | |
# This connection will do for database-independent bug reports. | |
# ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') | |
ActiveRecord::Base.establish_connection(adapter: 'postgresql', database: 'test') | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Schema.define do | |
unless ActiveRecord::Base.connection.table_exists?(:contacts) | |
create_table :contacts do |t| | |
t.string :company, :name | |
t.boolean :is_company | |
end | |
end | |
unless ActiveRecord::Base.connection.table_exists?(:properties) | |
create_table :properties do |t| | |
t.integer :contact_id | |
end | |
end | |
unless ActiveRecord::Base.connection.table_exists?(:things) | |
create_table :things do |t| | |
t.integer :property_id | |
end | |
end | |
end | |
class Contact < ActiveRecord::Base | |
has_many :properties | |
end | |
class Property < ActiveRecord::Base | |
belongs_to :contact | |
has_many :things | |
end | |
class Thing < ActiveRecord::Base | |
belongs_to :property | |
end | |
class BugTest < Minitest::Test | |
def test_stuff | |
# contact = Contact.create!(company: 'Basecamp', name: 'David Heinemeier Hansson') | |
q = Property.includes(:things, :contact) | |
q = q.order('CASE WHEN contacts.is_company THEN UPPER(contacts.company) ELSE UPPER(contacts.name) END').references(:contacts) | |
p q.limit(10) | |
# PG::SyntaxError | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
rails/rails#16623