Escape ticks
crappy hql version
merged HQL version