Sha256: 913b27ac5b9aafb0e22b241d853991336ce3195e3c53579d4b4cf0edf197e202

Contents?: true

Size: 798 Bytes

Versions: 2

Compression:

Stored size: 798 Bytes

Contents

module ActiveRecord
  module Associations
    class HasOneAssociation
      def construct_sql
        case
          when @reflection.options[:as]
            @finder_sql =
              "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_id = #{owner_quoted_id} AND " +
              "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote_value(@owner.class.base_class.name.to_s)}"
          else
            # CPK
            #@finder_sql = "#{@reflection.quoted_table_name}.#{@reflection.primary_key_name} = #{owner_quoted_id}"
            @finder_sql = full_columns_equals(@reflection.quoted_table_name, @reflection.cpk_primary_key, owner_quoted_id)
        end
        @finder_sql << " AND (#{conditions})" if conditions
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
composite_primary_keys-3.0.0.b3 lib/composite_primary_keys/associations/has_one_association.rb
composite_primary_keys-3.0.0.b2 lib/composite_primary_keys/associations/has_one_association.rb