Skip to content

Instantly share code, notes, and snippets.

@avsej
Created February 21, 2014 08:49
Show Gist options
  • Select an option

  • Save avsej/9130856 to your computer and use it in GitHub Desktop.

Select an option

Save avsej/9130856 to your computer and use it in GitHub Desktop.
require 'active_record'
require 'logger'
ActiveRecord::Base.establish_connection(adapter: 'postgresql', database: 'avsej')
ActiveRecord::Schema.define do
create_table :users, force: true do |t|
t.string :first_name
t.string :last_name
t.string :role
end
end
class User < ActiveRecord::Base; end
puts "without squeel: #{User.where(role: 'admin').where_values.inspect}"
require 'squeel'
puts "with squeel: #{User.where(role: 'admin').where_values.inspect}"
# -- create_table(:users, {:force=>true})
# -> 0.0240s
# without squeel: [#<Arel::Nodes::Equality:0x00000001f32450 @left=#<struct Arel::Attributes::Attribute relation=#<Arel::Table:0x00000001f2a868 @name="users", @engine=User(id: integer, first_name: string, last_name: string, role: string), @columns=nil, @aliases=[], @table_alias=nil, @primary_key=nil>, name="role">, @right="admin">]
# with squeel: [{:role=>"admin"}]
#=> nil
# 0.270000 0.030000 0.300000 ( 0.336954)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment