@@ -110,16 +110,20 @@ def resolve_attributes(record, attributes)
110
110
111
111
def build_relation ( klass , attribute , value )
112
112
relation = klass . unscoped
113
- comparison = relation . bind_attribute ( attribute , value ) do |attr , bind |
114
- return relation . none! if bind . unboundable?
113
+ # TODO: Add case-sensitive / case-insensitive operators to Arel
114
+ # to no longer need to checkout a connection here.
115
+ comparison = klass . with_connection do |connection |
116
+ relation . bind_attribute ( attribute , value ) do |attr , bind |
117
+ return relation . none! if bind . unboundable?
115
118
116
- if !options . key? ( :case_sensitive ) || bind . nil?
117
- klass . lease_connection . default_uniqueness_comparison ( attr , bind )
118
- elsif options [ :case_sensitive ]
119
- klass . lease_connection . case_sensitive_comparison ( attr , bind )
120
- else
121
- # will use SQL LOWER function before comparison, unless it detects a case insensitive collation
122
- klass . lease_connection . case_insensitive_comparison ( attr , bind )
119
+ if !options . key? ( :case_sensitive ) || bind . nil?
120
+ connection . default_uniqueness_comparison ( attr , bind )
121
+ elsif options [ :case_sensitive ]
122
+ connection . case_sensitive_comparison ( attr , bind )
123
+ else
124
+ # will use SQL LOWER function before comparison, unless it detects a case insensitive collation
125
+ connection . case_insensitive_comparison ( attr , bind )
126
+ end
123
127
end
124
128
end
125
129
0 commit comments