Sha256: 7e9f003269ba29be81106a69eb9033a5469b34681eca7d049bb1d0ca880abd83

Contents?: true

Size: 600 Bytes

Versions: 23

Compression:

Stored size: 600 Bytes

Contents

module CompositePrimaryKeys
  module ActiveRecord
    module QueryMethods
      def reverse_order
        order_clause = arel.order_clauses

        # CPK
        # order = order_clause.empty? ?
        #  "#{table_name}.#{primary_key} DESC" :
        #  reverse_sql_order(order_clause).join(', ')

        order = unless order_clause.empty?
          reverse_sql_order(order_clause).join(', ')
        else
          klass.primary_key.map do |key|
            "#{table_name}.#{key} DESC"
          end.join(", ")
        end

        except(:order).order(Arel.sql(order))
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
composite_primary_keys-5.0.10 lib/composite_primary_keys/relation/query_methods.rb
composite_primary_keys-5.0.9 lib/composite_primary_keys/relation/query_methods.rb
composite_primary_keys-5.0.8 lib/composite_primary_keys/relation/query_methods.rb
composite_primary_keys-5.0.6 lib/composite_primary_keys/relation/query_methods.rb
composite_primary_keys-5.0.5 lib/composite_primary_keys/relation/query_methods.rb
composite_primary_keys-5.0.4 lib/composite_primary_keys/relation/query_methods.rb
composite_primary_keys-5.0.2 lib/composite_primary_keys/relation/query_methods.rb
composite_primary_keys-5.0.1 lib/composite_primary_keys/relation/query_methods.rb
composite_primary_keys-5.0.0 lib/composite_primary_keys/relation/query_methods.rb
composite_primary_keys-5.0.0.rc1 lib/composite_primary_keys/relation/query_methods.rb
composite_primary_keys-4.1.2 lib/composite_primary_keys/relation/query_methods.rb
composite_primary_keys-4.1.1 lib/composite_primary_keys/relation/query_methods.rb
composite_primary_keys-4.0.0 lib/composite_primary_keys/relation/query_methods.rb
composite_primary_keys-4.0.0.beta9 lib/composite_primary_keys/relation/query_methods.rb
composite_primary_keys-4.0.0.beta8 lib/composite_primary_keys/relation/query_methods.rb
composite_primary_keys-4.0.0.beta7 lib/composite_primary_keys/relation/query_methods.rb
composite_primary_keys-4.0.0.beta6 lib/composite_primary_keys/relation/query_methods.rb
composite_primary_keys-4.0.0.beta5 lib/composite_primary_keys/relation/query_methods.rb
composite_primary_keys-4.0.0.beta4 lib/composite_primary_keys/relation/query_methods.rb
composite_primary_keys-4.0.0.beta3 lib/composite_primary_keys/relation/query_methods.rb