aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-09-01 13:11:15 +0200
committerJeremy Kemper <jeremy@bitsweat.net>2009-09-01 10:15:23 -0700
commitda636809daca9c338200811d3590e446f57c8e81 (patch)
treeac2a678c61836fa695542343591fbbc145c3d7d5 /activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
parentc5f6e038daf2221ddd5a7534e68f4158d84a5975 (diff)
downloadrails-da636809daca9c338200811d3590e446f57c8e81.tar.gz
rails-da636809daca9c338200811d3590e446f57c8e81.tar.bz2
rails-da636809daca9c338200811d3590e446f57c8e81.zip
Assert primary key does not exist in habtm when the association is defined, instead of doing that everytime a record is inserted.
[#3128 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb')
-rw-r--r--activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb16
1 files changed, 0 insertions, 16 deletions
diff --git a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
index d91c555dad..fd23e59e82 100644
--- a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
+++ b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
@@ -1,11 +1,6 @@
module ActiveRecord
module Associations
class HasAndBelongsToManyAssociation < AssociationCollection #:nodoc:
- def initialize(owner, reflection)
- super
- @primary_key_list = {}
- end
-
def create(attributes = {})
create_record(attributes) { |record| insert_record(record) }
end
@@ -22,12 +17,6 @@ module ActiveRecord
@reflection.reset_column_information
end
- def has_primary_key?
- return @has_primary_key unless @has_primary_key.nil?
- @has_primary_key = (ActiveRecord::Base.connection.supports_primary_key? &&
- ActiveRecord::Base.connection.primary_key(@reflection.options[:join_table]))
- end
-
protected
def construct_find_options!(options)
options[:joins] = @join_sql
@@ -40,11 +29,6 @@ module ActiveRecord
end
def insert_record(record, force = true, validate = true)
- if has_primary_key?
- raise ActiveRecord::ConfigurationError,
- "Primary key is not allowed in a has_and_belongs_to_many join table (#{@reflection.options[:join_table]})."
- end
-
if record.new_record?
if force
record.save!