Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Extract common query to a constant.

  • Loading branch information...
commit e7e28a71be68271c7892477c1b9336316a1871bc 1 parent 01d4941
@vipulnsward vipulnsward authored
Showing with 3 additions and 1 deletion.
  1. +3 −1 activerecord/lib/active_record/relation/finder_methods.rb
View
4 activerecord/lib/active_record/relation/finder_methods.rb
@@ -1,5 +1,7 @@
module ActiveRecord
module FinderMethods
+ ONE_AS_ONE = '1 AS one'
+
# Find by id - This can either be a specific id (1), a list of ids (1, 5, 6), or an array of ids ([5, 6, 10]).
# If no record can be found for all of the listed ids, then RecordNotFound will be raised. If the primary key
# is an integer, find by id coerces its arguments using +to_i+.
@@ -202,7 +204,7 @@ def exists?(conditions = :none)
relation = construct_relation_for_association_find(construct_join_dependency)
return false if ActiveRecord::NullRelation === relation
- relation = relation.except(:select, :order).select("1 AS one").limit(1)
+ relation = relation.except(:select, :order).select(ONE_AS_ONE).limit(1)
case conditions
when Array, Hash
Please sign in to comment.
Something went wrong with that request. Please try again.