Method: ModelSet::SQLQuery#ids

Defined in:
lib/model_set/sql_query.rb

#idsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/model_set/sql_query.rb', line 19

def ids
  if @ids.nil?
    if @limit_fetch
      base_conditions = conditions
      @ids = [].to_ordered_set
      @reorder.each_slice(@limit_fetch) do |ids|
        self.conditions = to_conditions(:and, ids_clause(ids), *base_conditions)
        @ids.concat fetch_id_set(sql)
        if limit and @ids.size >= limit
          @ids.reorder!(@reorder).limit!(limit)
          break
        end
      end
      self.conditions = base_conditions
    else
      @ids = fetch_id_set(sql)
      @ids.reorder!(@reorder) if @reorder
    end
  end
  @ids
end