Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Resolve issue #534 #1318

Merged
merged 2 commits into from

2 participants

@TheEmpty

Removes the restriction on primary key when joining in a habtm && test that it was properly removed

So I saw issue #534 and thought that it looked simple and gave it a try. Added a test to prove that it works fine without it. First commit pretty nervous that I just screwed everything up or something :P so anyway, hope I understood the ticket correctly and the code is satisfactory.

@jonleighton jonleighton merged commit 09e431a into rails:master
@jake3030 jake3030 referenced this pull request from a commit in jake3030/rails
@mocoso mocoso Fixed method_missing for ActionMailer so it no longer matches methods…
… where deliver or create are not a suffix [#1318 state:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
c65075f
@dmathieu dmathieu referenced this pull request from a commit
@dmathieu dmathieu cherry-pick #1318 into 3-1-stable 5b20d4c
@shwoodard shwoodard referenced this pull request from a commit in shwoodard/rails-1
@shwoodard shwoodard Merge branch '3-1-stable' of github.com:rails/rails into 3-1-stable
* '3-1-stable' of github.com:rails/rails: (91 commits)
  Merge pull request #3049 from brainopia/fix_to_query_edge_case
  Bump AR-JDBC version. THis version is compatible with 3.1 and above
  Revert "Fixed Apache configuration for gzipped assets: FilesMatch and LocationMatch cannot be nested."
  Fixed Apache configuration for gzipped assets: FilesMatch and LocationMatch cannot be nested. (cherry picked from commit 5e2bf4d)
  Proper lines numbers for stack trace info
  Merge pull request #3040 from guilleiguaran/asset-host-should-not-be-nil-precompile
  cherry-pick #1318 into 3-1-stable
  Bumping up to 3.1.1.rc1
  Add some CHANGELOG missing stuff
  Allow asset tag helper methods to accept :digest => false option in order to completely avoid the digest generation.
  Add equivalent nginx configuration
  Fix typos and broken link on asset pipeline guide
  Merge pull request #3015 from guilleiguaran/clear-tmp-cache-on-precompile
  Merge pull request #3012 from guilleiguaran/3-1-1-changelogs
  Revert "Provide a way to access to assets without using the digest, useful for static files and emails"
  Merge pull request #3011 from guilleiguaran/disable-sprockets-server
  Provide a way to access to assets without using the digest, useful for static files and emails
  Merge pull request #2922 from wayneeseguin/master
  getting_started.textile: Fix typo and split up a sentence in section "Building a Multi-Model Form"
  getting_started.textile: Fix typos in section "Rendering a Partial Form"
  ...
4b2c9a9
@ttosch ttosch referenced this pull request from a commit
@dmathieu dmathieu cherry-pick #1318 into 3-1-stable 4712b04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 26, 2011
  1. @TheEmpty

    Removes the restriction on primary key when joining in a habtm && tes…

    TheEmpty authored
    …t that it was properly removed
  2. @TheEmpty
This page is out of date. Refresh to see the latest.
View
6 activerecord/lib/active_record/associations.rb
@@ -76,12 +76,6 @@ def initialize(owner, reflection)
end
end
- class HasAndBelongsToManyAssociationWithPrimaryKeyError < ActiveRecordError #:nodoc:
- def initialize(reflection)
- super("Primary key is not allowed in a has_and_belongs_to_many join table (#{reflection.options[:join_table]}).")
- end
- end
-
class HasAndBelongsToManyAssociationForeignKeyNeeded < ActiveRecordError #:nodoc:
def initialize(reflection)
super("Cannot create self referential has_and_belongs_to_many association on '#{reflection.class_name rescue nil}##{reflection.name rescue nil}'. :association_foreign_key cannot be the same as the :foreign_key.")
View
4 activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb
@@ -39,10 +39,6 @@ def check_validity(reflection)
model.send(:undecorated_table_name, model.to_s),
model.send(:undecorated_table_name, reflection.class_name)
)
-
- if model.connection.supports_primary_key? && (model.connection.primary_key(reflection.options[:join_table]) rescue false)
- raise ActiveRecord::HasAndBelongsToManyAssociationWithPrimaryKeyError.new(reflection)
- end
end
# Generates a join table name from two provided table names.
View
9 activerecord/test/cases/associations/habtm_join_table_test.rb
@@ -32,13 +32,4 @@ def teardown
ActiveRecord::Base.connection.drop_table :my_readers
ActiveRecord::Base.connection.drop_table :my_books_my_readers
end
-
- uses_transaction :test_should_raise_exception_when_join_table_has_a_primary_key
- def test_should_raise_exception_when_join_table_has_a_primary_key
- if ActiveRecord::Base.connection.supports_primary_key?
- assert_raise ActiveRecord::HasAndBelongsToManyAssociationWithPrimaryKeyError do
- MyReader.has_and_belongs_to_many :my_books
- end
- end
- end
end
Something went wrong with that request. Please try again.