Sha256: f087342d7d53fd95cd40c4f1ee010c54df5c92f985713eee6779edf9fb80d731
Contents?: true
Size: 626 Bytes
Versions: 6
Compression:
Stored size: 626 Bytes
Contents
require 'sql/maker/select' class SQL::Maker::Select::Oracle < SQL::Maker::Select ## Oracle doesn't have the LIMIT clause. def as_limit return '' end ## Override as_sql to emulate the LIMIT clause. def as_sql limit = self.limit offset = self.offset if limit && offset self.add_select( "ROW_NUMBER() OVER (ORDER BY 1) R" ) end sql = super if limit sql = "SELECT * FROM ( #{sql} ) WHERE " if offset sql = sql + " R BETWEEN #{offset} + 1 AND #{limit} + #{offset}" else sql = sql + " rownum <= #{limit}" end end return sql end end
Version data entries
6 entries across 6 versions & 1 rubygems