Sha256: 195b2c2547943a3f8b1e5be21d79790dd22aa4459201bffb297a8e62594e8638

Contents?: true

Size: 961 Bytes

Versions: 2

Compression:

Stored size: 961 Bytes

Contents

module Arel
  module Visitors
    class SQLServer
      def make_Fetch_Possible_And_Deterministic o
        return if o.limit.nil? && o.offset.nil?
        t = table_From_Statement o
        pk = primary_Key_From_Table t
        return unless pk
        if o.orders.empty?
          # Prefer deterministic vs a simple `(SELECT NULL)` expr.
          # CPK
          #o.orders = [pk.asc]
          o.orders = pk.map {|a_pk| a_pk.asc}
        end
      end

      def primary_Key_From_Table t
        return unless t
        column_name = schema_cache.primary_keys(t.name) || column_cache(t.name).first.second.try(:name)

        # CPK
        # column_name ? t[column_name] : nil
        case column_name
          when Array
            column_name.map do |name|
              t[name]
            end
          when NilClass
            [t[column_name]]
          else
            nil
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
composite_primary_keys-9.0.6 lib/composite_primary_keys/arel/sqlserver.rb
composite_primary_keys-9.0.5 lib/composite_primary_keys/arel/sqlserver.rb