Method: Sequel::Dataset#select_order_map
- Defined in:
- lib/sequel/dataset/actions.rb
#select_order_map(column = nil, &block) ⇒ Object
The same as select_map, but in addition orders the array by the column.
DB[:table].select_order_map(:id) # SELECT id FROM table ORDER BY id
# => [1, 2, 3, 4, ...]
DB[:table].select_order_map{id * 2} # SELECT (id * 2) FROM table ORDER BY (id * 2)
# => [2, 4, 6, 8, ...]
You can also provide an array of column names:
DB[:table].select_order_map([:id, :name]) # SELECT id, name FROM table ORDER BY id, name
# => [[1, 'A'], [2, 'B'], [3, 'C'], ...]
If you provide an array of expressions, you must be sure that each entry in the array has an alias that Sequel can determine.
794 795 796 |
# File 'lib/sequel/dataset/actions.rb', line 794 def select_order_map(column=nil, &block) _select_map(column, true, &block) end |