Fix bug deriving the type of a join-key.