fix relation handling when source table equals foreign table