Fixed #22960: Bad handling of relations as PKs in autodetector