Flowdock
method

add_limit_offset!

Importance_1
v1.2.0 - Show latest stable - 1 note - Class: ActiveRecord::ConnectionAdapters::DB2Adapter
add_limit_offset!(sql, options) public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Show source
Register or log in to add new notes.
April 14, 2011
0 thanks

Why gsub!

I notice other adapters use sql.sub!, not sql.gsub! and in fact I had trouble with adding the limit parameter to any query involving nested selects. Replacing sql.gsub! with sql.sub! solved that problem for me. Has anyone else had a similar experience with this method?

In other words, replace:

sql.gsub!(/SELECT/i, 'SELECT B.* FROM (SELECT A.*, row_number() over () AS internal$rownum FROM (SELECT')

With:

sql.sub!(/SELECT/i, 'SELECT B.* FROM (SELECT A.*, row_number() over () AS internal$rownum FROM (SELECT')