Skip to content

Provide pluck_by_sql method for Rails ActiveRecord models

License

Notifications You must be signed in to change notification settings

aamine/sql_pluck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sql_pluck gem

Provide #pluck_by_sql method for Rails ActiveRecord models. You can execute arbitrary SQL and get bare attribute values without creating ActiveRecord objects, while values are casted to appropreate types.

Usage:

class SomeModel < ActiveRecord::Base
  extend SQLPluck
end

SomeModel.pluck_by_sql('select id, name from some_model where id % 777 = 0')
# => [[777, 'name777'], [1554, 'name1554'], ...]

SomeModel.pluck_by_sql(['select id, name from some_model where created_at > ?', time])
# => [[1901, 'name1901'], [1902, 'name1902'], ...]

About

Provide pluck_by_sql method for Rails ActiveRecord models

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages