Add SQL function to raise exceptions
Add direct relation dependency tests