Add string escape for postgresql for custom query