Fixed error information about query and parameters on failure, foreign relations.