Sha256: c257f5fadf22d0493e7435190c5c275498567c6c7c5d9c7312faf13ea1717cfe

Contents?: true

Size: 487 Bytes

Versions: 15

Compression:

Stored size: 487 Bytes

Contents

class ModelSet
  class RawSQLQuery < SQLBaseQuery
    def sql=(sql)
      @sql = sanitize_condition(sql)
      ['LIMIT', 'OFFSET'].each do |term|
        raise "#{term} not permitted in raw sql" if @sql.match(/ #{term} \d+/i)
      end
    end
    
    def sql
      "#{@sql} #{limit_clause}"
    end

    def count
      # The only way to get the count if there is a limit is to fetch all ids without the limit.
      @count ||= limit ? fetch_id_set(@sql).size : size
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
ninjudd-model_set-0.10.0 lib/model_set/raw_sql_query.rb
ninjudd-model_set-0.10.1 lib/model_set/raw_sql_query.rb
ninjudd-model_set-0.10.2 lib/model_set/raw_sql_query.rb
ninjudd-model_set-0.10.3 lib/model_set/raw_sql_query.rb
ninjudd-model_set-0.10.4 lib/model_set/raw_sql_query.rb
ninjudd-model_set-0.10.5 lib/model_set/raw_sql_query.rb
ninjudd-model_set-0.9.2 lib/model_set/raw_sql_query.rb
model_set-1.1.3 lib/model_set/raw_sql_query.rb
model_set-1.1.2 lib/model_set/raw_sql_query.rb
model_set-1.1.1 lib/model_set/raw_sql_query.rb
model_set-1.1.0 lib/model_set/raw_sql_query.rb
model_set-1.0.0 lib/model_set/raw_sql_query.rb
model_set-0.11.1 lib/model_set/raw_sql_query.rb
model_set-0.11.0 lib/model_set/raw_sql_query.rb
model_set-0.10.6 lib/model_set/raw_sql_query.rb