fixed sql problem introduced from patches that were merged in