fix the errors in getDatabaseQuery