Sha256: 044ac94c4a4b528521788d2acdf3222b0c2826cbd0659e2a433b20e1a3f5c641

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

module ActiveRecord
  class NonScalarPrimaryKeyError < ::ActiveRecord::ActiveRecordError
    def initialize(reflection)
      super("Can not join association #{reflection.name.inspect}, because :primary_key is a callable. Use Relation#includes or specify a join column name")
    end
  end

  module Associations
    class JoinDependency
      class JoinAssociation
        def initialize(reflection, join_dependency, parent = nil)
          reflection.check_validity!

          # PATCH here
          if reflection.options[:primary_key].respond_to?(:call)
            raise NonScalarPrimaryKeyError.new(reflection)
          end
          # end PATCH

          if reflection.options[:polymorphic]
            raise EagerLoadPolymorphicError.new(reflection)
          end

          super(reflection.klass)

          @reflection      = reflection
          @join_dependency = join_dependency
          @parent          = parent
          @join_type       = Arel::InnerJoin
          @aliased_prefix  = "t#{ join_dependency.join_parts.size }"
          @tables          = construct_tables.reverse
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
includes_many-0.1.0 lib/includes_many/active_record32/join_association.rb