Fix for wrong duplicate SQL detection. (#788)