Fix bug in query with names are None