Fix bug in lockTable method where an empty query was being set