anchor.diff:    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
  +    s = a.referenced_entity.subtypes.select{|st| !st.abstract? }.size
       cols = (0...(s)).collect do |index|
         "#{ref_prefix}#{index}.#{col_name}"
       end.join(", ")
  
positive.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{|a| !a.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 )";
  
negative.code: -%>
  <% if a.referenced_entity.abstract? -%>
        "   (T.<%= entity.sync.sync_temp_entity.attribute_by_name("#{a.name}MappingID").sql.quoted_column_name %> IS NULL OR (" +
  <% a.referenced_entity.subtypes.select{|st| !st.abstract? }.each_with_index do |subtype, index| -%>
    "R<%= reference_index %><%= index %>.<%= entity.sync.master_entity.attribute_by_name(a.name).referenced_entity.primary_key.sql.quoted_column_name %> IS NOT NULL AND " +
  <% end -%>
        " 1 = 1 )" +
  