Skip to content

Instantly share code, notes, and snippets.

@etehtsea
Created October 14, 2015 10:53
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 etehtsea/7fd4eff4441190c34b32 to your computer and use it in GitHub Desktop.
Save etehtsea/7fd4eff4441190c34b32 to your computer and use it in GitHub Desktop.
require 'bundler/inline'
gemfile(true) do
source 'https://rubygems.org'
gem 'activerecord', '4.2.4'
gem 'sqlite3'
end
require 'active_record'
require 'minitest/autorun'
require 'logger'
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table(:things) do |t|
t.boolean :hidden
end
end
class Thing < ActiveRecord::Base
scope :hidden, -> { where(hidden: true) }
end
class ReproTest < Minitest::Test
def test_generates_correct_where_sql
sql = Thing.hidden.arel.where_sql
puts sql
assert sql == "WHERE \"things\".\"hidden\" = 't'"
end
end
# 4.2.2: WHERE "things"."hidden" = 't'
# 4.2.3: WHERE "things"."hidden" = ?
# 4.2.4: WHERE "things"."hidden" = ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment