Skip to content

Commit ef99277

Browse files
authored
Merge pull request #751 from aidanharan/exists-relation-sanitize-forbidden-attributes
Rails 6: Sanitize forbidden attributes for exists relation
2 parents ae1bccd + a25eddb commit ef99277

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/active_record/connection_adapters/sqlserver/core_ext/finder_methods.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ module FinderMethods
1111

1212
# Same as original except we order by values in distinct select if present.
1313
def construct_relation_for_exists(conditions)
14-
if distinct_value && offset_value
15-
relation = limit!(1)
14+
conditions = sanitize_forbidden_attributes(conditions)
1615

16+
if distinct_value && offset_value
1717
if select_values.present?
18-
relation = relation.order(*select_values)
18+
relation = order(*select_values).limit!(1)
1919
else
20-
relation = relation.except(:order)
20+
relation = except(:order).limit!(1)
2121
end
2222
else
2323
relation = except(:select, :distinct, :order)._select!(::ActiveRecord::FinderMethods::ONE_AS_ONE).limit!(1)

0 commit comments

Comments
 (0)