Last active
          September 29, 2016 12:35 
        
      - 
      
- 
        Save rootatdarkstar/91f12bb72a21313a5024a9c0c6a5629d to your computer and use it in GitHub Desktop. 
    Attempt to fix https://github.com/rails/arel/issues/438
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | if o.limit && o.offset | |
| o = o.dup | |
| limit = o.limit.expr | |
| offset = o.offset | |
| o.offset = nil | |
| collector << " | |
| SELECT * FROM ( | |
| SELECT raw_sql_.*, rownum raw_rnum_ | |
| FROM (" | |
| collector = super(o, collector) | |
| collector << ") raw_sql_ | |
| WHERE rownum <= (" | |
| collector = collector.add_bind(offset.expr) { |i| ":a#{i}" } | |
| @limit_placeholder = nil | |
| collector << " + " | |
| collector = collector.add_bind(limit) { |i| @limit_placeholder = ":a#{i}" } | |
| collector << ") | |
| ) | |
| WHERE " | |
| collector << "raw_rnum_ > #{@limit_placeholder}" | |
| return collector | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment