Permalink
Browse files

Add test to column alias in `exists?` SQL.

This behavior was added in be4ecdc.

Closes #1139.

Fixes #2553, #1141, #1623 and #2062.
  • Loading branch information...
1 parent be4ecdc commit 6cc5e9aa81870a8a4ef1582b34abfb4deff7d115 @rafaelfranca rafaelfranca committed Jun 10, 2012
@@ -106,7 +106,7 @@ def first!
# Person.last # returns the last object fetched by SELECT * FROM people
# Person.where(["user_name = ?", user_name]).last
# Person.order("created_on DESC").offset(5).last
- # Person.last(3) # returns the last three objects fetched by SELECT * FROM people.
+ # Person.last(3) # returns the last three objects fetched by SELECT * FROM people.
#
# Take note that in that last case, the results are sorted in ascending order:
#
@@ -45,6 +45,12 @@ def test_exists
assert_raise(NoMethodError) { Topic.exists?([1,2]) }
end
+ def test_exists_does_not_select_columns_without_alias
+ assert_sql(/SELECT\W+1 AS _one FROM ["`]topics["`]\W+LIMIT 1/) do
+ Topic.exists?
+ end
+ end
+
def test_exists_returns_true_with_one_record_and_no_args
assert Topic.exists?
end

0 comments on commit 6cc5e9a

Please sign in to comment.