sql escape dialect refactored to sql macro