anchor.diff:  <% elsif a.referenced_entity.abstract? -%>
   <%
     refs = []
  -  a.referenced_entity.subtypes.select{|a| !a.abstract? }.each_with_index do |subtype, index|
  +  a.referenced_entity.subtypes.select{|st| !st.abstract? }.each_with_index do |subtype, index|
       refs << "R#{index}"
   -%>
             " LEFT JOIN <%= subtype.sync.master_entity.sql.qualified_table_name %> AS R<%= index %> ON R<%= index %>.MappingID = S.<%= entity.sync.sync_temp_entity.attribute_by_name("#{a.name}MappingID").sql.quoted_column_name %> AND R<%= index %>.MappingSource = S.MappingSource AND R<%= index %>.DeletedAt IS NULL " +
  
positive.code:   col_name = entity.sync.master_entity.attribute_by_name(a.name).referenced_entity.primary_key.sql.quoted_column_name
    ref_prefix = "R#{reference_index}"
    if a.referenced_entity.abstract?
      s = a.referenced_entity.subtypes.select{|a| !a.abstract? }.size
      cols = (0...(s)).collect do |index|
        "#{ref_prefix}#{index}.#{col_name}"
      end.join(", ")
  
negative.code:           " WHERE S.<%= entity.sync.sync_temp_entity.attribute_by_name("#{a.name}MappingID").sql.quoted_column_name %> IS NOT NULL AND S.<%= entity.sync.master_entity.attribute_by_name(:MappingSource).sql.quoted_column_name %> = ? AND " +
  <% if a.referenced_entity.abstract? -%>
            "(" +
  <% a.referenced_entity.subtypes.select{|st| !st.abstract? }.each_with_index do |subtype, index| -%>
              "O<%= index %>.<%= subtype.sync.master_entity.attribute_by_name(:MappingID).sql.quoted_column_name %> IS NULL AND " +
  <% end -%>
            " 1 = 1 )";
  