File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed
lib/composite_primary_keys Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -5,9 +5,9 @@ def visit_CompositePrimaryKeys_CompositeKeys o, collector
55 values = o . map do |key |
66 case key
77 when Arel ::Attributes ::Attribute
8- "#{ key . relation . name } .#{ key . name } "
8+ "#{ quote_table_name ( key . relation . name ) } .#{ quote_column_name ( key . name ) } "
99 else
10- key
10+ quote_column_name ( key )
1111 end
1212 end
1313 collector << "(#{ values . join ( ', ' ) } )"
Original file line number Diff line number Diff line change @@ -173,8 +173,8 @@ def cpk_exists_subquery(stmt)
173173 #
174174 # UPDATE `reference_codes`
175175 # SET ...
176- # WHERE (reference_codes. reference_type_id, reference_codes. reference_code) IN
177- # (SELECT reference_type_id, reference_code
176+ # WHERE (` reference_codes`.` reference_type_id`, ` reference_codes`.` reference_code` ) IN
177+ # (SELECT ` reference_type_id`,` reference_code`
178178 # FROM (SELECT DISTINCT `reference_codes`.`reference_type_id`, `reference_codes`.`reference_code`
179179 # FROM `reference_codes`) __active_record_temp)
180180 def cpk_mysql_subquery ( stmt )
@@ -189,7 +189,9 @@ def cpk_mysql_subquery(stmt)
189189 # to work with MySQL 5.7.6 which sets optimizer_switch='derived_merge=on'
190190 subselect . distinct unless arel . limit || arel . offset || arel . orders . any?
191191
192- key_name = arel_attributes . map ( &:name ) . join ( ',' )
192+ key_name = arel_attributes . map ( &:name ) . map do |name |
193+ connection . quote_column_name ( name )
194+ end . join ( ',' )
193195
194196 manager = Arel ::SelectManager . new ( subselect . as ( "__active_record_temp" ) ) . project ( Arel . sql ( key_name ) )
195197
You can’t perform that action at this time.
0 commit comments