fixed issue 1342:MySQL, self-reference, and null values