Created
October 4, 2011 09:21
-
-
Save jonleighton/1261220 to your computer and use it in GitHub Desktop.
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
| gem 'rails', '3.1.1.rc2' | |
| require 'active_record' | |
| puts "Active Record #{ActiveRecord::VERSION::STRING}" | |
| ActiveRecord::Base.establish_connection( | |
| :adapter => 'sqlite3', | |
| :database => ':memory:' | |
| ) | |
| ActiveRecord::Schema.define do | |
| create_table :apps, :force => true do |t| | |
| end | |
| create_table :permissions, :force => true do |t| | |
| t.integer :app_id | |
| end | |
| end | |
| class App < ActiveRecord::Base | |
| end | |
| class Permission < ActiveRecord::Base | |
| belongs_to :app | |
| end | |
| query = Permission.joins(:app) | |
| puts query.to_sql |
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
| $ ruby ~/Desktop/bug3207.rb | |
| Active Record 3.1.1.rc2 | |
| -- create_table(:apps, {:force=>true}) | |
| -> 0.0537s | |
| -- create_table(:permissions, {:force=>true}) | |
| -> 0.0010s | |
| SELECT "permissions".* FROM "permissions" INNER JOIN "apps" ON "apps"."id" = "permissions"."app_id" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment