Class: ActiveRecord::Associations::HasAndBelongsToManyAssociation

Inherits:
AssociationCollection
  • Object
show all
Defined in:
lib/composite_primary_keys/associations.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#construct_sqlObject



313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/composite_primary_keys/associations.rb', line 313

def construct_sql
  @reflection.options[:finder_sql] &&= interpolate_sql(@reflection.options[:finder_sql])

  if @reflection.options[:finder_sql]
    @finder_sql = @reflection.options[:finder_sql]
  else
    @finder_sql = full_columns_equals(@reflection.options[:join_table], @reflection.primary_key_name, @owner.quoted_id)
    @finder_sql << " AND (#{conditions})" if conditions
  end

  @join_sql = "INNER JOIN #{@reflection.active_record.connection.quote_table_name(@reflection.options[:join_table])} ON " +
  full_composite_join_clause(@reflection.klass.table_name, @reflection.klass.primary_key, @reflection.options[:join_table], @reflection.association_foreign_key)
end