Sha256: d33c94c36a90281bd13bef5bcd44fd33eabfe18bf2eb1a602dc26b831965c916
Contents?: true
Size: 952 Bytes
Versions: 1
Compression:
Stored size: 952 Bytes
Contents
module Arel module Visitors class SybaseJtds < Arel::Visitors::ToSql def select_count? o sel = o.cores.length == 1 && o.cores.first projections = sel.projections.length == 1 && sel.projections Arel::Nodes::Count === projections.first end def visit_Arel_Nodes_SelectStatement o if o.offset || (o.limit && select_count?(o)) o.offset.expr += 1 if o.offset sql = super # if offset OR (limit & count) use the Java limit/offset/count parser else limit = o.limit o.limit = nil sql = super if limit limit_and_no_offset sql, limit end end sql end def limit_and_no_offset sql, limit if sql =~ /DISTINCT / sql.gsub!(/DISTINCT /, "DISTINCT TOP #{limit} ") else sql.gsub!(/SELECT /, "SELECT TOP #{limit} ") end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ar-sybase-jdbc-adapter-0.1.1 | lib/arel/visitors/sybase_jtds.rb |