Fixed AttributeError about _sql for --query.