Fix escaping of ' in SQL