Sha256: 362f03d0923ea115e732b129c8cda30587c53c3dee96c043f8216082abc0bb43

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

module Arel
  module SqlCompiler
    class MsSQLCompiler < GenericCompiler
      def select_sql
        query = super
        
        offset = relation.skipped
        limit = relation.taken
        @engine.connection.add_limit_offset!(query, :limit => limit, :offset => offset) if offset || limit
    
        query
      end
      
      def build_clauses
        joins   = relation.joins(self)
        wheres  = relation.where_clauses
        groups  = relation.group_clauses
        havings = relation.having_clauses
        orders  = relation.order_clauses

        clauses = [ "",
          joins,
          ("WHERE     #{wheres.join(' AND ')}" unless wheres.empty?),
          ("GROUP BY  #{groups.join(', ')}" unless groups.empty?),
          ("HAVING    #{havings.join(' AND ')}" unless havings.empty?),
          ("ORDER BY  #{orders.join(', ')}" unless orders.empty?)
        ].compact.join ' '

        clauses << " #{locked}" unless locked.blank?
        clauses unless clauses.blank?
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activerecord-jdbc-adapter-1.0.0.beta2-java lib/arel/engines/sql/compilers/mssql_compiler.rb