File tree Expand file tree Collapse file tree 2 files changed +10
-16
lines changed
activerecord/lib/active_record Expand file tree Collapse file tree 2 files changed +10
-16
lines changed Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ def many?
99
99
if block_given?
100
100
to_a . many? { |*block_args | yield ( *block_args ) }
101
101
else
102
- @limit_value . present? ? to_a . many? : size > 1
102
+ @limit_value ? to_a . many? : size > 1
103
103
end
104
104
end
105
105
@@ -316,12 +316,12 @@ def to_sql
316
316
317
317
def scope_for_create
318
318
@scope_for_create ||= begin
319
- @create_with_value || @where_values . inject ( { } ) do | hash , where |
320
- if where . is_a? ( Arel ::Predicates ::Equality )
321
- hash [ where . operand1 . name ] = where . operand2 . respond_to? ( :value ) ? where . operand2 . value : where . operand2
322
- end
323
- hash
324
- end
319
+ @create_with_value || Hash [
320
+ @where_values . grep ( Arel ::Predicates ::Equality ) . map { | where |
321
+ [ where . operand1 . name ,
322
+ where . operand2 . respond_to? ( :value ) ?
323
+ where . operand2 . value : where . operand2 ]
324
+ } ]
325
325
end
326
326
end
327
327
Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ def custom_join_sql(*joins)
129
129
def build_arel
130
130
arel = table
131
131
132
- arel = build_joins ( arel , @joins_values ) if @joins_values . present ?
132
+ arel = build_joins ( arel , @joins_values ) unless @joins_values . empty ?
133
133
134
134
@where_values . uniq . each do |where |
135
135
next if where . blank?
@@ -145,7 +145,7 @@ def build_arel
145
145
146
146
arel = arel . having ( *@having_values . uniq . select { |h | h . present? } ) if @having_values . present?
147
147
148
- arel = arel . take ( @limit_value ) if @limit_value . present?
148
+ arel = arel . take ( @limit_value ) if @limit_value
149
149
arel = arel . skip ( @offset_value ) if @offset_value . present?
150
150
151
151
arel = arel . group ( *@group_values . uniq . select { |g | g . present? } ) if @group_values . present?
@@ -155,13 +155,7 @@ def build_arel
155
155
arel = build_select ( arel , @select_values . uniq )
156
156
157
157
arel = arel . from ( @from_value ) if @from_value . present?
158
-
159
- case @lock_value
160
- when TrueClass
161
- arel = arel . lock
162
- when String
163
- arel = arel . lock ( @lock_value )
164
- end if @lock_value . present?
158
+ arel = arel . lock ( @lock_value ) if @lock_value
165
159
166
160
arel
167
161
end
You can’t perform that action at this time.
0 commit comments