@@ -64,19 +64,19 @@ def find_fragments(filters, options = {})
64
64
records = find_records ( filters , options )
65
65
66
66
table_name = _model_class . table_name
67
- pluck_fields = [ "#{ concat_table_field ( table_name , _primary_key ) } AS #{ table_name } _#{ _primary_key } " ]
67
+ pluck_fields = [ Arel . sql ( "#{ concat_table_field ( table_name , _primary_key ) } AS #{ table_name } _#{ _primary_key } " ) ]
68
68
69
69
cache_field = attribute_to_model_field ( :_cache_field ) if options [ :cache ]
70
70
if cache_field
71
- pluck_fields << "#{ concat_table_field ( table_name , cache_field [ :name ] ) } AS #{ table_name } _#{ cache_field [ :name ] } "
71
+ pluck_fields << Arel . sql ( "#{ concat_table_field ( table_name , cache_field [ :name ] ) } AS #{ table_name } _#{ cache_field [ :name ] } " )
72
72
end
73
73
74
74
model_fields = { }
75
75
attributes = options [ :attributes ]
76
76
attributes . try ( :each ) do |attribute |
77
77
model_field = attribute_to_model_field ( attribute )
78
78
model_fields [ attribute ] = model_field
79
- pluck_fields << "#{ concat_table_field ( table_name , model_field [ :name ] ) } AS #{ table_name } _#{ model_field [ :name ] } "
79
+ pluck_fields << Arel . sql ( "#{ concat_table_field ( table_name , model_field [ :name ] ) } AS #{ table_name } _#{ model_field [ :name ] } " )
80
80
end
81
81
82
82
fragments = { }
@@ -204,21 +204,21 @@ def find_related_monomorphic_fragments(source_rids, relationship, included_key,
204
204
records = related_klass . apply_filters ( records , filters , filter_options )
205
205
206
206
pluck_fields = [
207
- "#{ primary_key_field } AS #{ _table_name } _#{ _primary_key } " ,
208
- "#{ concat_table_field ( table_alias , related_klass . _primary_key ) } AS #{ table_alias } _#{ related_klass . _primary_key } "
207
+ Arel . sql ( "#{ primary_key_field } AS #{ _table_name } _#{ _primary_key } " ) ,
208
+ Arel . sql ( "#{ concat_table_field ( table_alias , related_klass . _primary_key ) } AS #{ table_alias } _#{ related_klass . _primary_key } " )
209
209
]
210
210
211
211
cache_field = related_klass . attribute_to_model_field ( :_cache_field ) if options [ :cache ]
212
212
if cache_field
213
- pluck_fields << "#{ concat_table_field ( table_alias , cache_field [ :name ] ) } AS #{ table_alias } _#{ cache_field [ :name ] } "
213
+ pluck_fields << Arel . sql ( "#{ concat_table_field ( table_alias , cache_field [ :name ] ) } AS #{ table_alias } _#{ cache_field [ :name ] } " )
214
214
end
215
215
216
216
model_fields = { }
217
217
attributes = options [ :attributes ]
218
218
attributes . try ( :each ) do |attribute |
219
219
model_field = related_klass . attribute_to_model_field ( attribute )
220
220
model_fields [ attribute ] = model_field
221
- pluck_fields << "#{ concat_table_field ( table_alias , model_field [ :name ] ) } AS #{ table_alias } _#{ model_field [ :name ] } "
221
+ pluck_fields << Arel . sql ( "#{ concat_table_field ( table_alias , model_field [ :name ] ) } AS #{ table_alias } _#{ model_field [ :name ] } " )
222
222
end
223
223
224
224
rows = records . pluck ( *pluck_fields )
@@ -265,9 +265,9 @@ def find_related_polymorphic_fragments(source_rids, relationship, options = {})
265
265
related_type = concat_table_field ( _table_name , relationship . polymorphic_type )
266
266
267
267
pluck_fields = [
268
- "#{ primary_key } AS #{ _table_name } _#{ _primary_key } " ,
269
- "#{ related_key } AS #{ _table_name } _#{ relationship . foreign_key } " ,
270
- "#{ related_type } AS #{ _table_name } _#{ relationship . polymorphic_type } "
268
+ Arel . sql ( "#{ primary_key } AS #{ _table_name } _#{ _primary_key } " ) ,
269
+ Arel . sql ( "#{ related_key } AS #{ _table_name } _#{ relationship . foreign_key } " ) ,
270
+ Arel . sql ( "#{ related_type } AS #{ _table_name } _#{ relationship . polymorphic_type } " )
271
271
]
272
272
273
273
relations = relationship . polymorphic_relations
0 commit comments