Reject self joins

Fixes #349.