aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2010-07-19 15:32:00 -0400
committerAaron Patterson <aaron.patterson@gmail.com>2010-07-20 16:45:42 -0700
commitf576d7cf848717384799a9e9669b253ccc94deb5 (patch)
tree4cf0e9c980e133c713374477e17411236f24aaf6 /activerecord/test/cases/associations
parenta63566dda8246bd57e80032a1213532d0dc2ae0b (diff)
downloadrails-f576d7cf848717384799a9e9669b253ccc94deb5.tar.gz
rails-f576d7cf848717384799a9e9669b253ccc94deb5.tar.bz2
rails-f576d7cf848717384799a9e9669b253ccc94deb5.zip
Ensure that primary_keys of HABTM records is not double quoted
[#5152 state:reslved]
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r--activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
index b11969a841..d4d3d8e43e 100644
--- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
@@ -24,6 +24,8 @@ require 'models/club'
require 'models/member'
require 'models/membership'
require 'models/sponsor'
+require 'models/country'
+require 'models/treaty'
require 'active_support/core_ext/string/conversions'
class ProjectWithAfterCreateHook < ActiveRecord::Base
@@ -83,6 +85,22 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase
fixtures :accounts, :companies, :categories, :posts, :categories_posts, :developers, :projects, :developers_projects,
:parrots, :pirates, :treasures, :price_estimates, :tags, :taggings
+ def test_should_property_quote_string_primary_keys
+ country = Country.new(:name => 'India')
+ country.country_id = 'c1'
+ country.save!
+
+ treaty = Treaty.new(:name => 'peace')
+ treaty.treaty_id = 't1'
+ country.treaties << treaty
+
+ con = ActiveRecord::Base.connection
+ sql = 'select * from countries_treaties'
+ record = con.select_rows(sql).last
+ assert_equal 'c1', record[0]
+ assert_equal 't1', record[1]
+ end
+
def test_has_and_belongs_to_many
david = Developer.find(1)