aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2007-11-10 21:33:13 +0000
committerMichael Koziarski <michael@koziarski.com>2007-11-10 21:33:13 +0000
commit79823e0b2fa3b6d34aca1945d25e2f2574635823 (patch)
tree03500e20ac76e74e9e0bb0910cf2b743bbcfb433 /activerecord/test
parent0f2c6302a19abce498d6cdbd44df0131c51fc8a3 (diff)
downloadrails-79823e0b2fa3b6d34aca1945d25e2f2574635823.tar.gz
rails-79823e0b2fa3b6d34aca1945d25e2f2574635823.tar.bz2
rails-79823e0b2fa3b6d34aca1945d25e2f2574635823.zip
Ensure that column names are quoted. Closes #10134 [wesley.moxam]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8126 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/associations/inner_join_association_test.rb14
-rw-r--r--activerecord/test/reserved_word_test_mysql.rb4
2 files changed, 11 insertions, 7 deletions
diff --git a/activerecord/test/associations/inner_join_association_test.rb b/activerecord/test/associations/inner_join_association_test.rb
index 983f269e87..8d583f2138 100644
--- a/activerecord/test/associations/inner_join_association_test.rb
+++ b/activerecord/test/associations/inner_join_association_test.rb
@@ -10,30 +10,30 @@ class InnerJoinAssociationTest < Test::Unit::TestCase
def test_construct_finder_sql_creates_inner_joins
sql = Author.send(:construct_finder_sql, :joins => :posts)
- assert_match /INNER JOIN posts ON posts.author_id = authors.id/, sql
+ assert_match /INNER JOIN `?posts`? ON `?posts`?.author_id = authors.id/, sql
end
def test_construct_finder_sql_cascades_inner_joins
sql = Author.send(:construct_finder_sql, :joins => {:posts => :comments})
- assert_match /INNER JOIN posts ON posts.author_id = authors.id/, sql
- assert_match /INNER JOIN comments ON comments.post_id = posts.id/, sql
+ assert_match /INNER JOIN `?posts`? ON `?posts`?.author_id = authors.id/, sql
+ assert_match /INNER JOIN `?comments`? ON `?comments`?.post_id = posts.id/, sql
end
def test_construct_finder_sql_inner_joins_through_associations
sql = Author.send(:construct_finder_sql, :joins => :categorized_posts)
- assert_match /INNER JOIN categorizations.*INNER JOIN posts/, sql
+ assert_match /INNER JOIN `?categorizations`?.*INNER JOIN `?posts`?/, sql
end
def test_construct_finder_sql_applies_association_conditions
sql = Author.send(:construct_finder_sql, :joins => :categories_like_general, :conditions => "TERMINATING_MARKER")
- assert_match /INNER JOIN categories ON.*AND.*'General'.*TERMINATING_MARKER/, sql
+ assert_match /INNER JOIN `?categories`? ON.*AND.*`?General`?.*TERMINATING_MARKER/, sql
end
def test_construct_finder_sql_unpacks_nested_joins
sql = Author.send(:construct_finder_sql, :joins => {:posts => [[:comments]]})
assert_no_match /inner join.*inner join.*inner join/i, sql, "only two join clauses should be present"
- assert_match /INNER JOIN posts ON posts.author_id = authors.id/, sql
- assert_match /INNER JOIN comments ON comments.post_id = posts.id/, sql
+ assert_match /INNER JOIN `?posts`? ON `?posts`?.author_id = authors.id/, sql
+ assert_match /INNER JOIN `?comments`? ON `?comments`?.post_id = `?posts`?.id/, sql
end
def test_construct_finder_sql_ignores_empty_joins_hash
diff --git a/activerecord/test/reserved_word_test_mysql.rb b/activerecord/test/reserved_word_test_mysql.rb
index 1a7b9a1ad5..10a9fca11e 100644
--- a/activerecord/test/reserved_word_test_mysql.rb
+++ b/activerecord/test/reserved_word_test_mysql.rb
@@ -147,6 +147,10 @@ class MysqlReservedWordTest < Test::Unit::TestCase
assert_nothing_raised { Group.count }
end
+ def test_associations_work_with_reserved_words
+ assert_nothing_raised { Select.find(:all, :include => [:groups]) }
+ end
+
#the following functions were added to DRY test cases
private