Method: Qreport::Connection#with_limit
- Defined in:
- lib/qreport/connection.rb
#with_limit(sql, limit = nil) ⇒ Object
306 307 308 309 310 311 312 313 314 315 316 317 318 |
# File 'lib/qreport/connection.rb', line 306 def with_limit sql, limit = nil sql = sql.dup case limit when Integer limit = "LIMIT #{limit}" when Array limit = "OFFSET #{limit[1].to_i}\nLIMIT #{limit[0].to_i}" end unless sql.sub!(/:LIMIT\b|\bLIMIT\s+\S+\s*|\Z/im, "\n#{limit}") sql << "\n" << limit end sql end |