There's a bug in the ANS contract where the primary name and the ANS don't point to the same registered address if a primary name token gets transfered. This caused the current_aptos_names view to show the wrong primary name because it joins only on token_name. We need to add a constraint to the left join on current_ans_lookup_v2.registered_address = current_ans_primary_name_v2.registered_address
Description
There's a bug in the ANS contract where the primary name and the ANS don't point to the same registered address if a primary name token gets transfered. This caused the
current_aptos_names
view to show the wrong primary name because it joins only ontoken_name
. We need to add a constraint to the left join oncurrent_ans_lookup_v2.registered_address = current_ans_primary_name_v2.registered_address
Testing
Run the SQL and see that is_primary = false