Skip to content

Instantly share code, notes, and snippets.

@manuelmeurer
Created March 5, 2014 17:25
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 manuelmeurer/9371941 to your computer and use it in GitHub Desktop.
Save manuelmeurer/9371941 to your computer and use it in GitHub Desktop.
Test for Rails issue #8748
GIT
remote: git://github.com/rails/arel.git
revision: 24995298face1d08ffb52f6c1b0374feeb7a380b
specs:
arel (5.0.0.20140210193626)
GIT
remote: git://github.com/rails/rails.git
revision: 058d3c6183ef6e0e878bea37f4fe3f8f0d6758e2
specs:
actionmailer (4.2.0.alpha)
actionpack (= 4.2.0.alpha)
actionview (= 4.2.0.alpha)
mail (~> 2.5.4)
actionpack (4.2.0.alpha)
actionview (= 4.2.0.alpha)
activesupport (= 4.2.0.alpha)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
actionview (4.2.0.alpha)
activesupport (= 4.2.0.alpha)
builder (~> 3.1)
erubis (~> 2.7.0)
activemodel (4.2.0.alpha)
activesupport (= 4.2.0.alpha)
builder (~> 3.1)
activerecord (4.2.0.alpha)
activemodel (= 4.2.0.alpha)
activesupport (= 4.2.0.alpha)
arel (~> 5.0.0)
activesupport (4.2.0.alpha)
i18n (~> 0.6, >= 0.6.9)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
rails (4.2.0.alpha)
actionmailer (= 4.2.0.alpha)
actionpack (= 4.2.0.alpha)
actionview (= 4.2.0.alpha)
activemodel (= 4.2.0.alpha)
activerecord (= 4.2.0.alpha)
activesupport (= 4.2.0.alpha)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.0.alpha)
sprockets-rails (~> 2.0.0)
railties (4.2.0.alpha)
actionpack (= 4.2.0.alpha)
activesupport (= 4.2.0.alpha)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
GEM
remote: https://rubygems.org/
specs:
atomic (1.1.15)
builder (3.2.2)
erubis (2.7.0)
hike (1.2.3)
i18n (0.6.9)
json (1.8.1)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.25.1)
minitest (5.3.0)
multi_json (1.9.0)
polyglot (0.3.4)
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
rake (10.1.1)
sprockets (2.11.0)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.0.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
sqlite3 (1.3.9)
thor (0.18.1)
thread_safe (0.2.0)
atomic (>= 1.1.7, < 2)
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (1.1.0)
thread_safe (~> 0.1)
PLATFORMS
ruby
DEPENDENCIES
arel!
rails!
sqlite3
-- create_table(:posts)
D, [2014-03-05T18:20:11.470910 #28767] DEBUG -- :  (0.5ms) CREATE TABLE "posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL) 
-> 0.0048s
-- create_table(:comments)
D, [2014-03-05T18:20:11.471516 #28767] DEBUG -- :  (0.1ms) CREATE TABLE "comments" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "post_id" integer)
-> 0.0005s
Run options: --seed 34242
# Running:
D, [2014-03-05T18:20:11.498107 #28767] DEBUG -- : Post Load (0.1ms) SELECT "posts".* FROM (SELECT comments.id FROM "posts" INNER JOIN "comments" ON "comments"."post_id" = "posts"."id") comments
E, [2014-03-05T18:20:11.498191 #28767] ERROR -- : SQLite3::SQLException: no such table: posts: SELECT "posts".* FROM (SELECT comments.id FROM "posts" INNER JOIN "comments" ON "comments"."post_id" = "posts"."id") comments
E
Finished in 0.008845s, 113.0582 runs/s, 0.0000 assertions/s.
1) Error:
BugTest#test_association_stuff:
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: posts: SELECT "posts".* FROM (SELECT comments.id FROM "posts" INNER JOIN "comments" ON "comments"."post_id" = "posts"."id") comments
/Users/manuel/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.9/lib/sqlite3/database.rb:91:in `initialize'
/Users/manuel/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.9/lib/sqlite3/database.rb:91:in `new'
/Users/manuel/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.9/lib/sqlite3/database.rb:91:in `prepare'
/Users/manuel/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/bundler/gems/rails-058d3c6183ef/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:301:in `block in exec_query'
/Users/manuel/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/bundler/gems/rails-058d3c6183ef/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:373:in `block in log'
/Users/manuel/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/bundler/gems/rails-058d3c6183ef/activesupport/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/Users/manuel/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/bundler/gems/rails-058d3c6183ef/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:367:in `log'
/Users/manuel/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/bundler/gems/rails-058d3c6183ef/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:298:in `exec_query'
/Users/manuel/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/bundler/gems/rails-058d3c6183ef/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:507:in `select'
/Users/manuel/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/bundler/gems/rails-058d3c6183ef/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:31:in `select_all'
/Users/manuel/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/bundler/gems/rails-058d3c6183ef/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:69:in `select_all'
/Users/manuel/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/bundler/gems/rails-058d3c6183ef/activerecord/lib/active_record/querying.rb:39:in `find_by_sql'
/Users/manuel/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/bundler/gems/rails-058d3c6183ef/activerecord/lib/active_record/relation.rb:603:in `exec_queries'
/Users/manuel/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/bundler/gems/rails-058d3c6183ef/activerecord/lib/active_record/relation.rb:487:in `load'
/Users/manuel/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/bundler/gems/rails-058d3c6183ef/activerecord/lib/active_record/relation.rb:231:in `to_a'
/Users/manuel/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/bundler/gems/rails-058d3c6183ef/activerecord/lib/active_record/relation.rb:586:in `blank?'
/Users/manuel/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/bundler/gems/rails-058d3c6183ef/activesupport/lib/active_support/core_ext/object/blank.rb:24:in `present?'
/Users/manuel/code/test_app_rails_issue_8748/rails_master/test.rb:45:in `test_association_stuff'
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
[Finished in 1.9s with exit code 1]
[shell_cmd: ruby "/Users/manuel/code/test_app_rails_issue_8748/rails_master/test.rb"]
[dir: /Users/manuel/code/test_app_rails_issue_8748/rails_master]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
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
require 'bundler'
Bundler.setup(:default)
require 'active_record'
require 'minitest/autorun'
require 'logger'
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :posts do |t|
end
create_table :comments do |t|
t.integer :post_id
end
end
class Post < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :post
end
class BugTest < Minitest::Test
def test_association_stuff
q1 = Post.joins(:comments).select('comments.id').as('comments')
q2 = Post.from(q1).includes(:comments)
q2.present?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment